How can you extract a specific range of values from an array in PHP?

To extract a specific range of values from an array in PHP, you can use the array_slice() function. This function allows you to extract a portion of an array based on the start index and length of the range you want to extract. By specifying the start index and length, you can easily extract the desired range of values from the array.

// Sample array
$array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];

// Extract values from index 2 to 5
$range = array_slice($array, 2, 4);

print_r($range); // Output: Array ( [0] => 3 [1] => 4 [2] => 5 [3] => 6 )