Learning PHP
Advanced PHP
PHP Function Reference
PHP Useful Resources
Selected Reading
© 2011 TutorialsPoint.COM
|
PHP Function array_unshift()
Syntax
array_unshift($array,$value1,$value2,$value3...)
|
Definition and Usage
This function returns an array containing all the values of array1 that are present in all the arguments array2, array3.
Paramters
Parameter | Description |
array | Required. Specifies an array. |
value1 | Required. Specifies a value to insert |
value2 | Optional. Specifies a value to insert |
value3 | Optional. Specifies a value to insert |
Example
Try out following example:
<?php
$queue = array("orange", "banana");
array_unshift($queue, "apple", "raspberry");
print_r($queue);
?>
|
This will produce following result:
Array
(
[0] => apple
[1] => raspberry
[2] => orange
[3] => banana
)
|
|
|
|