I want to display 10 highest figure and 10 lowest figure in a multi-dimensional array.
I have figured out way to display the maximum figure using max()
, but when I use min()
, the least less value get looped again and again for 10 times e.g 2.
How can I reuse my code to display minimum value in my array?
$totalCustomer = count($customerArray);
$postion = 0;
foreach ($customerArray as $custom) {
$postion = $postion + 1;
if($totalCustomer - $postion < 9){
$top[] = $custom['spend'];
$maxprice = max($top);
echo "Max spend price is ". $maxprice. "<br>";
}
}