$array1 = array(0,1,3,0);
$array2 = array(2,0,3,2);
$array3 = array(0,4,5,1);
echo min($array1) . "\n";
echo min($array2) . "\n";
echo min($array3) . "\n";
this return me:
0
0
0
but i want receive:
1
2
1
How to skip 0 in function MIN?
Find minimum value excluding zero with formula 1. Select a blank cell (H1) for placing the minimum value, enter formula =SMALL(A1:E7,COUNTIF($A$1:$E$7,0)+1) into the Formula Bar, and then press the Enter key.
Try array_filter:
If no callback is supplied, all entries of input equal to FALSE will be removed.
so it will remove 0
for you.
echo min(array_filter($array1)) . "\n";
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