Remove items from an array after a certain point with array_splice

Posted 2 years ago

To remove items after a certain point you should be using array_splice.


$name = array("Chris", "Danny", "Benjamin", "Keith");
$cut = array_splice($name, 2);

var_dump($cut);
// outputs is an array ("Chris", "Danny") as we're using the first 2 items


Read up on array_splice here : http://php.net/manual/en/function.array-splice.php