array_splice
array_splice
is used to remove a portion of array and can be replaced with new value.
array array_splice ( array &input, int offset [, int length [, array replacement]] )
<?php
$arr = array(’one’,'two’,'three’,'four’);
array_splice($arr,3)
/// $arr will now contain array(’one’,'two’,'three’)
$arr = array(’one’,'two’,'three’,'four’);
array_splice($arr,1,-1)
/* $arr will now contain array(’one’,'four’)
which means remove the portion start from offset 1
and remove upto (final offsest -1)
*/
$arr = array(’one’,'two’,'three’,'four’);
array_splice($arr,1,3,”five”)
/* $arr will now contain array(’one’,'five’)
*/
?>
