You can use array_unshift() to insert an element or elements at the start of an array.
The function returns the new number of elements in the array.
For example:
<?php $authors = array("A","B","C","D"); echo array_unshift($authors,"Hardy","M")."\n"; // Displays"6" print_r($authors);/*from w ww . jav a 2s . co m*/ ?>
You can't add key/value pairs to associative arrays using array_unshift() or its counterpart, array_pop().