Is using a foreach loop with a counter variable a recommended approach to determine the last iteration in PHP?

Using a foreach loop with a counter variable to determine the last iteration is not a recommended approach in PHP. Instead, you can use the `end()` function to get the last element of an array and compare it with the current element in the loop to determine if it's the last iteration.

$items = ['apple', 'banana', 'orange'];

foreach ($items as $key => $item) {
    if ($item === end($items)) {
        echo "Last item: $item";
    } else {
        echo "$item, ";
    }
}