$a = array("0"=>array("id"=>332,"name"=>"myname"),"1"=>array("id"=>333,"name"=>"yourname");如何变为下面的格式?$a = array("0"=>array("id"=>332,"name"=>"myname","district"=>"mydistrict"),"1"=>array("id"=>333,"name"=>"yourname","district"=>"testdistrict");
你要添加的值是固定的 还是随机的 还是你要设置好的?
你要添加的值是固定的 还是随机的 还是你要设置好的?
$a = array("0"=>array("id"=>332,"name"=>"myname"),"1"=>array("id"=>333,"name"=>"yourname");foreach($a as &$v){ $v['district'] = 'xxx';}unset($v);
$a = array("0"=>array("id"=>332,"name"=>"myname"),"1"=>array("id"=>333,"name"=>"yourname");foreach($a as $k=>$v){ $a[$k]['district'] = 'mydistrict';}print_r($a);
$v[] = 'xx';