我有一个数组,看起来像这样:PHP阵列重新安排
array(3) {
["title"]=>
array(3) {
[0]=>
string(3) "one"
[1]=>
string(3) "two"
[2]=>
string(4) "test"
}
["file"]=>
array(3) {
[0]=>
string(25) "company_handbook_2011.pdf"
[1]=>
string(8) "test.doc"
[2]=>
string(8) "test.doc"
}
["status"]=>
array(3) {
[0]=>
string(4) "SHOW"
[1]=>
string(4) "HIDE"
[2]=>
string(4) "HIDE"
}
}
我怎么可以重新安排它看起来像这样:
array(
array(
"one",
"company_handbook_2011.pdf",
"SHOW"
),
array(
"two",
"test.doc",
"HIDE"
),
array(
"test",
"test.doc",
"HIDE"
),
)
即得到各的第一要素数组和和构建一个新的数组,然后第二个元素等。非常感谢您的帮助。
对此,我认为没有现成的功能。你必须简单地遍历循环中的数组,然后构建它 – 2011-04-07 15:41:30
由于索引似乎在不同的键之间匹配,所以您不必遍历数组。你可以统计数字'$ array ['title']',然后使用一个简单的for循环从正确的位置获取值来构造一个新的数组。基准测试哪种方法更快会很有趣。 – Capsule 2011-04-07 15:44:43
非常感谢你们提供的一些有用的信息...非常感谢你的时间。 array_map完成了这项工作。 – bharath 2011-04-07 15:56:24