php数组合并
<br />$a=Array<br />(<br /> [0] => Array<br /> (<br /> [newsupdate_id] => 1<br /> )<br /> [1] => Array<br /> (<br /> [newsupdate_id] => 2<br /> )<br />}<br /> <br />$b=Array<br />(<br /> [0] => 张三<br /> [1] => 李四<br />}<br /> <br />想要的结果<br />$c=Array<br />(<br /> [0] => Array<br /> (<br /> [newsupdate_id] => 1<br /> [newsupdate_name] => 张三<br /> )<br /> [1] => Array<br /> (<br /> [newsupdate_id] => 2<br /> [newsupdate_name] => 李四<br /> )<br />}<br />
$a = array(<br /> array('newsupdate_id' => 1),<br /> array('newsupdate_id' => 2),<br />);<br /> <br />$b = array('张三', '李四');<br /><br />foreach($a as $i=>$v) {<br /> $c[] = array_merge($v, array('newsupdate_name' => $b[$i]));<br />}<br />print_r($c);
Array<br />(<br /> [0] => Array<br /> (<br /> [newsupdate_id] => 1<br /> [newsupdate_name] => 张三<br /> )<br /><br /> [1] => Array<br /> (<br /> [newsupdate_id] => 2<br /> [newsupdate_name] => 李四<br /> )<br /><br />)<br /><br />