Rumah > Artikel > pembangunan bahagian belakang > 怎么将接收到的数组转成如下格式
如何将接收到的数组转成如下格式?
<input type="text" name="name[]" value="姓名" /><br /> <input type="text" name="age[]" value="15" /><br /> <input type="text" name="name[]" value="姓名" /><br /> <input type="text" name="age[]" value="15" />我要怎么接收,才能成这样的数组?pic=>(<br /> * 0=>array(<br /> * name=>姓名<br /> * age=>15<br /> * ),<br /> 0=>array(<br /> * name=>姓名<br /> * age=>30<br /> * ),
Array<br /> (<br /> [url] => Array<br /> (<br /> [0] => /uploads/13534190820.84986000.jpg<br /> [1] => /uploads/13534190830.00999000.jpg<br /> [2] => /uploads/13534190830.09639600.jpg<br /> [3] => /uploads/13534190830.18655000.jpg<br /> )<br /> <br /> [alt] => Array<br /> (<br /> [0] => 24234<br /> [1] => 23423<br /> [2] => 424<br /> [3] => 24234<br /> )<br /> <br /> )
foreach($_POST['name'] as $k=>$v){<br /> $arr[]=array('name'=>$v,'age'=>$_POST['age'][$k]);<br /> }<br /> print_r($arr);