将索引数组中的每两个元素转换为关联数组


Convert every two elements in an indexed array to form an associative array

我有一个这样的数组:

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

我需要转换成这个:

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

任何想法?

for ($i = 0; $i < count($myArray); $i += 2)
    $newArray[ $myArray[$i] ] = $myArray[$i+1];