Convert every two elements in an indexed array to form an associative array
arrays, associative-array, php
Solution
for ($i = 0; $i < count($myArray); $i += 2)
$newArray[ $myArray[$i] ] = $myArray[$i+1];
Problem
I have an array like this: ``` Array ( [0] => name [1] => john [2] => last [3] => doe [4] => company [5] => sony ) ``` I need to convert to this: ``` Array ( [name] => john [last] => doe [company] => sony ) ``` Any ideas?