function getSubset($array, $startIndex, $length) {
// Extract a subset of the array
return array_slice($array, $startIndex, $length);
}
$arr = [3, 7, 9, 0, 4, 2, 1, 8];
$startIndex = 2; // Start index for the subset
$length = 4; // Number of elements in the subset
$subset = getSubset($arr, $startIndex, $length);
echo "Subset: " . implode(", ", $subset) . PHP_EOL;
/*
run:
Subset: 9, 0, 4, 2
*/