I know how to insert it to the end by:
$arr[] = $item;
But how to insert it to the beginning?
In case of an associative array or numbered array where you do not want to change the array keys:
$firstItem = array('foo' => 'bar'); $arr = $firstItem + $arr;
array_merge does not work as it always reindexes the array.
array_merge