What is the purpose of finding the largest value in an array without using the max() function in PHP?

When finding the largest value in an array without using the max() function in PHP, you can iterate through the array and keep track of the current largest value found. Compare each element in the array with the current largest value and update it if a larger value is found.

$array = [3, 7, 2, 9, 5];
$largest = $array[0];

foreach ($array as $value) {
    if ($value > $largest) {
        $largest = $value;
    }
}

echo "The largest value in the array is: " . $largest;