What is the potential issue with the PHP code provided for selecting 3 random elements and sorting them alphabetically?

The potential issue with the provided PHP code is that it is sorting all elements alphabetically instead of just the 3 randomly selected elements. To solve this issue, you can first select 3 random elements from the array, sort them alphabetically, and then output the sorted elements.

// Original PHP code
$items = ['Apple', 'Banana', 'Orange', 'Grape', 'Cherry'];
$randomItems = array_rand($items, 3);
sort($randomItems);

foreach ($randomItems as $index) {
    echo $items[$index] . "\n";
}
```

```php
// Fixed PHP code
$items = ['Apple', 'Banana', 'Orange', 'Grape', 'Cherry'];
$randomKeys = array_rand($items, 3);
$randomItems = [];

foreach ($randomKeys as $key) {
    $randomItems[] = $items[$key];
}

sort($randomItems);

foreach ($randomItems as $item) {
    echo $item . "\n";
}