php过滤多维数组,该如何处理
程序员文章站
2024-02-09 13:08:28
...
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 *
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相关文章
相关视频