array_unshift for multidimensional arrays array_unshift for multidimensional arrays arrays arrays

array_unshift for multidimensional arrays


array_unshift should work for you. It should be noted that the function modifies the array passed to it and does not return a new array, so you should not be assigning the return value back to the array variable.

Correct:

array_unshift($arr, $newArray);

Incorrect:

$arr = array_unshift($arr, $newArray);