Tutorials Point


  Learning PHP
  Advanced PHP
  PHP Function Reference
  PHP Useful Resources
  Selected Reading

Copyright © 2014 by tutorialspoint



  Home     References     Discussion Forums     About TP  

PHP Function array_unshift()


previous

Advertisements

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

ParameterDescription
arrayRequired. Specifies an array.
value1Required. Specifies a value to insert
value2Optional. Specifies a value to insert
value3Optional. 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
)

previous Printer Friendly

Advertisements


  

Advertisements