Home >Backend Development >PHP Tutorial > 怎么将接收到的数组转成如上格式

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

WBOY
WBOYOriginal
2016-06-13 13:04:57763browse

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

<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);

------其他解决方案--------------------
没看懂。表单没贴全?
------其他解决方案--------------------
贴全了。我是POST提交,
然后生成相对应的两数数组。

引用:
没看懂。表单没贴全?

------其他解决方案--------------------
那和下面的数组有什么关系? 
------其他解决方案--------------------
表示同样没看懂
------其他解决方案--------------------
我是想生成
Array<br>
(<br>
    [0] => Array<br>
        (<br>
            [url] => /uploads/1562313.84986000.jpg<br>
            [alt]=>24234<br>
        )<br>
 <br>
    [1] => Array <div class="clear">
                 
              
              
        
            </div>
Statement:
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