Home >> PHP >> array_unshift() function in PHP

array_unshift() function in PHP

The array_unshift() function used for inserts new one or more elements at beginning of an array.

Syntax

array_unshift(array,value1,value2...)

Example

$array=array("shyam","ravi");

print_r(array_unshift($array,"ram","rajiv"));

print_r($array);

Output

4

Array ( [0] => ram [1] => rajiv [2] => shyam [3] => ravi )

 

Post Your Comment

Next Questions
array_values() function
array_walk() function
array_walk_recursive() function
asort() function
arsort() function
compact() function
count() function
current() function
each() function
end() function
extract() function
in_array() function
key() function
krsort() function
ksort() function
list() function
natcasesort() function
natsort() function
pos() function
prev() function
range() function
reset() function
rsort() function
shuffle() function
sizeof() function

Copyright ©2022 coderraj.com. All Rights Reserved.