array_splice

Syntax:array array_splice ( array &$input , int $offset [, int $length = 0 [, mixed $replacement ]] )
Description:Remove a portion of the array and replace it with something else

<?php
$input = array("red", "green", "blue", "yellow");
array_splice($input, 2);
print_r($input);
echo "<br/>";
$input = array("red", "green", "blue", "yellow");
array_splice($input, 1, -1);
print_r($input);
?>

OUTPUT

Array ( 
[0] => red 
[1] => green 
) 

Array ( 
[0] => red 
[1] => yellow 
)

 

Leave a Reply

Your email address will not be published. Required fields are marked *