array_slice() is used to extract a slice of an array. It returns the sequence of elements from the array as specified by the parameters.
<?php
$languageArray = array(“php”, “java”, “c++”, “pearl”, “python”);
$languages = array_slice($languageArray,0 ,2);
print_r($languages);
?>
OUTPUT: Array ( [0] => php [1] => java )