Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps!

We spend hours on Instagram and YouTube and waste money on coffee and fast food, but won’t spend 30 minutes a day learning skills to boost our careers.
Master in DevOps, SRE, DevSecOps & MLOps!

Learn from Guru Rajesh Kumar and double your salary in just one year.

Get Started Now!

Find Maximum and Minimum in an Array: Write a PHP function to find the maximum and minimum values in an array.

function findMinMax($arr) {
    $min = min($arr);
    $max = max($arr);
    return ["min" => $min, "max" => $max];
}

// Example usage:
$array = [3, 7, 2, 9, 1, 6];
$result = findMinMax($array);
echo "Minimum value: " . $result["min"] . ", Maximum value: " . $result["max"];

Related Posts

Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x
Artificial Intelligence