3

我有一个这样的数组:

Array
(
    [0] => name
    [1] => john
    [2] => last
    [3] => doe
    [4] => company
    [5] => sony
)

我需要转换为:

Array
(
    [name] => john
    [last] => doe
    [company] => sony
)

有任何想法吗?

4

1 回答 1

6
for ($i = 0; $i < count($myArray); $i += 2)
    $newArray[ $myArray[$i] ] = $myArray[$i+1];
于 2013-03-28T02:33:52.353 回答