Skip to content
Advertisement

how to display the maximum and minimum value of 5 data in an array

I created a php script to find the minimum and maximum values, but only 1 array data was detected, I want 5 maximal data and 5 minimum data, how it’s work?

JavaScript

Advertisement

Answer

JavaScript

output:

JavaScript

If the data is to be output as a list, this can be done with implode.

JavaScript

If the list of maximum values ​​should start at the highest value, $ max5 must be sorted again with rsort.

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement