Home >> PHP >> array_splice() function in PHP

array_splice() function in PHP

The array_splice() function used for removes selected elements from an array and replaces it with new elements.

Syntax

array_splice(array,start,length,array)

Example

$array1=array("a"=>"ram","b"=>"shyam","c"=>"ravi","d"=>"vinod");
$array2=array("a"=>"hari","b"=>"suresh");
array_splice($array1,0,2,$array2);
print_r($array1);

Output

Array ( [0] => hari [1] => suresh [c] => ravi [d] => vinod )

Post Your Comment

Next Questions
array_sum() function
array_udiff() function
array_udiff_assoc() function
array_udiff_uassoc() function
array_uintersect() function
array_uintersect_assoc() function
array_uintersect_uassoc() function
array_unique() function
array_unshift() function
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

Copyright ©2022 coderraj.com. All Rights Reserved.