array_slice and array_splice in php code example
Example 1: php array slice
$array = array(1,2,3,4,5,6);
print_r(array_slice($array, 2));
print_r(array_slice($array, -2));
print_r(array_slice($array, 2, 3));
print_r(array_slice($array, 2, -3));
Example 2: array splice php
<?php
$input = array("red", "green", "blue", "yellow");
array_splice($input, 2);
var_dump($input);
$input = array("red", "green", "blue", "yellow");
array_splice($input, 1, -1);
var_dump($input);
$input = array("red", "green", "blue", "yellow");
array_splice($input, 1, count($input), "orange");
var_dump($input);
$input = array("red", "green", "blue", "yellow");
array_splice($input, -1, 1, array("black", "maroon"));
var_dump($input);
?>