What is the purpose of using array_slice in the given PHP code snippet?
The purpose of using array_slice in the given PHP code snippet is to extract a portion of an array starting from a specified index and with a specified length. This allows us to manipulate or display only a subset of the original array's elements.
// Given PHP code snippet
$array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
$start_index = 2;
$length = 4;
// Using array_slice to extract a portion of the original array
$subset = array_slice($array, $start_index, $length);
// Displaying the subset of the array
print_r($subset);