In the context of PHP arrays, how can the correct indexing and numbering be maintained when outputting multiple elements using array_slice?

When using array_slice to output multiple elements from an array, the correct indexing and numbering can be maintained by adjusting the starting index parameter of array_slice to match the desired numbering. For example, if you want to start numbering elements from 1 instead of 0, you can set the starting index to 1. This way, the numbering will be consistent with the desired output.

$originalArray = ['apple', 'banana', 'cherry', 'date', 'elderberry'];

// Output elements starting from index 1 with correct numbering
$subsetArray = array_slice($originalArray, 1);
foreach ($subsetArray as $key => $value) {
    echo ($key + 1) . '. ' . $value . PHP_EOL;
}