<?PHP $a = array(1,2,3); array_unshift($a,0); print_r($a); //Array ( [0] => 0 [1] => 1 [2] => 2 [3] => 3 ) $a = array(1,2,3); array_unshift($a,0,9); print_r($a); //Array ( [0] => 0 [1] => 9 [2] => 1 [3] => 2 [4] => 3 ) $a = array(1,2,3); array_unshift($a,0,array(9,10,11)); print_r($a); //Array ( [0] => 0 [1] => Array ( [0] => 9 [1] => 10 [2] => 11 ) [2] => 1 [3] => 2 [4] => 3 ) ?>
Adds elements to the beginning of an associative array using
<?PHP $a = array("John"=>"Male","Mary"=>"Female"); $a=array_merge(array("George"=>"Male"),$a); print_r($a); //Array ( [George] => Male [John] => Male [Mary] => Female ) ?>
<?PHP $a = array(1,2,3); array_shift($a); print_r($a); //Array ( [0] => 2 [1] => 3 ) ?>
<?PHP $a = array("George"=>"Male","John"=>"Male","Mary"=>"Female"); array_shift($a); print_r($a); //Array ( [John] => Male [Mary] => Female ) ?>