PHP Programing language

array_unshift() Function in PHP
Previous Home Next

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

Tolal:0 Click:

Show All Comments

Did not find what you were looking for leave your name and message. We will revert within 24 hours
Name:
eMail:
Comment / Feedback: