30 seconds of PHP

  Back to Home

minN

matharrayintermediate

Returns the minimum value from the provided array.

Use array_filter() and min() to find the minimum value in an array.

function minN($numbers)
{
  $minValue = min($numbers);
  $minValueArray = array_filter($numbers, function ($value) use ($minValue) {
    return $minValue === $value;
  });

  return count($minValueArray);
}