数组操作技巧

遍历数组.重新命名,选择需要的下标和数据.可以遍历,放入新的数组中

$arr = array(
array("catid"=>"841","parentids"=>null,"childids"=>"842,843,943","name"=>"TV9","url"=>"http111"),
array("catid"=>"853","parentids"=>null,"childids"=>"854,855,856","name"=>"APP-ad","url"=>"http333"),
array("catid"=>"986","parentids"=>null,"childids"=>"988,989,990,991","name"=>"Appu64ad","url"=>"http666"),
array("catid"=>"987","parentids"=>null,"childids"=>"1015,1016,1017,1018","name"=>"Apbed","url"=>"http777"),
array("catid"=>"920","parentids"=>null,"childids"=>"922,921,923","name"=>"1APPd","url"=>"http0000")
);

foreach($arr as $k=>$v){
$menu[ ] = array('id'=>$v['catid'],'childids'=>$v['childids']);
$menu = array('id'=>$v['catid'],'childids'=>$v['childids']); //如果放入变量中.每次的值都会被后值覆盖掉.结果等于最后值
}

echo '

';
var_dump($menu);

你可能感兴趣的:(功能分类汇总)