如何将POST数组分成几组? [英] How to split POST array in groups?
本文介绍了如何将POST数组分成几组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要将每个数组的每个值添加到像person这样的新数组上。
I need each value of each array add on new array like person.
<div class="person">
<input name="name[]">
<input name="type[]">
</div>
<div class="person">
<input name="name[]">
<input name="type[]">
</div>
可能是两个人,十点左右也是动态的。
Could be two persons how also ten o more is dynamic.
$ _ POST返回以下内容:
$_POST return that:
Array( [name] => Array([0] => oliver [1] => tom) [type] => Array([0] => developer [1] => designer) )
我想要两个人分开的东西,但我尝试失败:
I want something like that the two persons separate, but i fail trying:
$person1 = array(
"name" => "oliver"
"type" => "developer"
)
$person2 = array(
"name" => "tom"
"type" => "designer"
)
推荐答案
$arr['name'] = $_POST['name'];
$arr['type'] = $_POST['type'];
array_unshift($arr, null);
print_r(call_user_func_array('array_map', $arr));
输出:
Array
(
[0] => Array
(
[0] => Oliver
[1] => developer
)
[1] => Array
(
[0] => Tom
[1] => designer
)
)
这篇关于如何将POST数组分成几组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文