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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.