i have searched through the Internet with no luck. I have array of integers and i want to check if my array contain positive value.
my array
$Myarray = {1,3,7,-6,-9,-23,-8};
i tried to use in_array() function
with no luck;
any help please?
A simple foreach
?
foreach($Myarray as $v)
{
if($v>0)
{
echo "Array contains a +ve value";
break;
}
}
Another way would be this..
$Myarray = array(-1,-3,-7,-6,-9,-23,-8);
rsort($Myarray);
echo ($Myarray[0] > 0) ? "Array contains +ve value" : "Array does not contain +ve value";