怎么将接收到的数组转成如下格式

WBOY
Release: 2016-06-13 12:50:54
Original
749 people have browsed it

如何将接收到的数组转成如下格式?

<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 />
     *          ),
Copy after login


我接收到的是这样

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 />
)
Copy after login

------解决方案--------------------
foreach($_POST['name'] as $k=>$v){<br />
   $arr[]=array('name'=>$v,'age'=>$_POST['age'][$k]);<br />
}<br />
print_r($arr);
Copy after login

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template