$input = array ("a", "b", "c", "d", "e"); $output = array_slice ($input, 2); / / returns "c", "d", and "e "$output = array_slice ($input, 2, -1); / / returns "c", "d" $output = array_slice ($input, -2, 1); / / returns "d "$output = array_slice ($input, 0, 3); / / returns "a", "b", and "c"
?php $input = array( "a", "b", "c", "d", "e"); $output = array_slice($input, 2); / / retourne "c", "d", et "e "/ / les trois exemples suivants sont équivalents $output = array_slice($input, 2, 2); / / retourne "c", "d" $output = array_slice($input, 2, -1); / / retourne "c", "d "/ / Equivalent à: $offset = 2; $length = -1; $output = array_slice($input, 2, count($input) - $offset + $length); / / retourne "c", "d" $output = array_slice($input, -2, 1); / / retourne "d "$output = array_slice($input, 0, 3); / / retourne "a", "b", et "c"?