What is the significance of using 'count($array) - 1' in a loop when iterating through an array in PHP?

When iterating through an array in PHP, using `count($array) - 1` is significant because it allows us to access the last element of the array without going out of bounds. This is necessary because array indices in PHP are zero-based, meaning the last element of the array is always at index `count($array) - 1`.

$array = [1, 2, 3, 4, 5];

for ($i = 0; $i < count($array); $i++) {
    if ($i == count($array) - 1) {
        echo "Last element: " . $array[$i];
    } else {
        echo $array[$i] . ", ";
    }
}