Jump to content

min(array) but ignoring 0s


debz89uk

Recommended Posts

Pass the array through array values, then to the min function.

 

$arr = array_values($DF); //array values with no second argument, strips out any value that is equivalent to boolean false.  This includes integer 0, or string 0.
$val = min($arr);

Pass the array through array values, then to the min function.

 

$arr = array_values($DF); //array values with no second argument, strips out any value that is equivalent to boolean false.  This includes integer 0, or string 0.
$val = min($arr);

 

I think you are referring to array_filter as array_values will just return all values from an array including zero's and other false-like values.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.