Home  >  Article  >  Backend Development  >  php过滤多维数组,该如何处理

php过滤多维数组,该如何处理

WBOY
WBOYOriginal
2016-06-13 10:54:26943browse

php过滤多维数组
Array ( 
[0] => Array ( 
[isxinx] => 1 
[rate] => 0.000 
[qs] => 177期预测 
[cb] => 20 
[title] => 【码到成功】福彩3D177期试机号前信心预测 
[id] => 4137166 
[userid] => 22843 
[childtype] => 试机号前 
[mfarticleid] => 0 
[author] => 码到成功 
[pubtime] => 2012-07-23 14:18:30 
[cptypeid] => 2 
[jtpath] => 
[num] => 2 
[ltitle] => 历史成绩 
[pm] => 10001 ) 
[1] => Array ( 
[isxinx] => 1 
[rate] => 0.000 
[qs] => 177期预测 
[cb] => 20 
[title] => 【码到成功】福彩3D177期试机号前信心预测 
[id] => 4137166 
[userid] => 22843 
[childtype] => 试机号前 
[mfarticleid] => 0 
[author] => 码到成功 
[pubtime] => 2012-07-23 14:18:30 
[cptypeid] => 2 
[jtpath] => 
[num] => 2 
[ltitle] => 历史成绩 
[pm] => 10001 ))

我现在就想取qs、cb、title、id、userid、author、ltitle
这七个字段的数据!请问一下这样怎么过滤掉其他的呢

------解决方案--------------------
foreach($arr as $v)
$ar[]=array('qs'=>$v['qs'],...............);

print_r($ar);
------解决方案--------------------
樓上回覆正確!
不過看的數據來源好像是從數據庫中獲取的,最好的方式應該是select的時候把字段名寫上,而应该避免使用select *

SQL code
select qs,cb,title,id,userid,author,ltitle from table<div class="clear">
                 
              
              
        
            </div>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn