How can one retrieve the highest value within a while loop in PHP?

To retrieve the highest value within a while loop in PHP, you can initialize a variable to store the highest value before entering the loop. Then, within the loop, compare each value to the current highest value and update the variable if a higher value is found. Finally, after the loop ends, the variable will contain the highest value.

$numbers = [5, 10, 3, 8, 15];
$highest = $numbers[0];

$i = 1;
while ($i < count($numbers)) {
    if ($numbers[$i] > $highest) {
        $highest = $numbers[$i];
    }
    $i++;
}

echo "The highest value is: " . $highest;