PHP Programing language

adplus-dvertising
array_unshift() Function in PHP
Previous Home Next
adplus-dvertising

array_unshift()

The array_unshift() function inserts new elements to an array. The new array values will be inserted in the beginning of the array.

Syntax:
array_unshift(array,value1,value2,value3...)

In above syntax, "array" specifying an array, "value1" specifies a value to insert, "value2" specifies a value to insert and "value3" specifies a value to insert.

Example:

<?php
$a=array("a"=>"Apple","b"=>"Mango");
array_unshift($a,"Orange");
print_r($a);
?>

Output:

Array ( [0] => Orange [a] => Apple [b] => Mango )

Previous Home Next