Back to Browse

Highest and lowest value from a PHP array by using max() and min() functions with array_search()

4.2K views
May 6, 2021
8:04

We can get highest and lowest value from an array by using max() and min() functions. https://www.plus2net.com/php_tutorial/array_max.php We can also get the respective keys of Maximum and Minimum values by using array_search() function. Function max() and min() returns the value only. $ar=array(25,26,47,14,29,58,15); echo max($ar); // output is 58 We can get the Key or index of the maximum value element by using array_search(), input to the array_search() function is the maximum or minimum value. $key=array_search(max($ar),$ar); echo $key; #phparraymax #phparraymin #highestvalue

Download

1 formats

Video Formats

360pmp410.5 MB

Right-click 'Download' and select 'Save Link As' if the file opens in a new tab.

Highest and lowest value from a PHP array by using max() and min() functions with array_search() | NatokHD