How do I check if in my array values is there a value bigger than 0?
Example:
array code {'0', '0', '0'}
Returns false.
array code_ii {'0', '1', '0'}
Returns true.
This should work for you:
(If one array element is bigger than 0 the entire array sum is bigger than 0 and you can return true)
<?php
$arr = array(0, 0 , 1);
if(array_sum($arr) > 0)
echo "true";
else
echo "false";
?>
Output:
true
You can use the following technique to get the value bigger than zero if present in array.
if (max(array(0,1,0)) > 0)
echo 'Array has value greater than 0';
Hope it will solve your problem or task. Thanks, Looking forward for the comments or queries if any.
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