tags:

views:

63

answers:

3

I know how to insert it to the end by:

$arr[] = $item;

But how to insert it to the beginning?

+3  A: 

Use function array_unshift

MaxiWheat
+3  A: 

array_unshift($array, $item);


$arr = array('item2', 'item3', 'item4');
array_unshift($arr , 'item1');
rockacola
+1  A: 

This will help

http://www.w3schools.com/php/func%5Farray%5Funshift.asp

array_unshift();