You can try declaring the variable $result, as an array, before using it.
$result = array();// Loop through and create a result array, with the key being even, the result, odd for($i = 0; $i < count($array)/2; $i++) { $result[$array[$i*2]] = $array[$i*2+1];}