What is the use of array_slice() in PHP ?

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.

str_split()
<?php

$languageArray = array(“php”, “java”, “c++”, “pearl”, “python”);
$languages = array_slice($languageArray,0 ,2);

print_r($languages);

?>

OUTPUT: Array ( [0] => php [1] => java )