我有一个这样的数组:
Array
(
[0] => name
[1] => john
[2] => last
[3] => doe
[4] => company
[5] => sony
)
我需要转换为:
Array
(
[name] => john
[last] => doe
[company] => sony
)
有什么想法吗?
答案 0 :(得分:6)
for ($i = 0; $i < count($myArray); $i += 2)
$newArray[ $myArray[$i] ] = $myArray[$i+1];