I would like to check if
$price_a = 30;
is greater than all the values in
$all_prices = [
1 => 12,
2 => 24,
3 => 32,
4 => 44
];
I guess I'd have to loop through the array and do the check for each iteration but I'm not sure how that loop should look like. Or is there a simpler solution?
You can check it by using max function of php :
<?php
if($price_a > max($all_prices)){
echo "Greater than all the values";
}
else{
echo "Smaller than ".max($all_prices);
}
?>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With