The min Function

The min function finds the smallest number from the parameters passed to it or the smallest number among the elements of an array.

Syntax

phpmin(first number, second number....);
phpmin(array of numbers);

Example

Let's find the smallest among the given numbers:

php<?php
  echo min(1, 2, 3);
?>

Code execution result:

php1

Example

Let's find the smallest value in the array:

php<?php
  echo min([1, 2, 3]);
?>

Code execution result:

php1

See Also

  • the max function,
    which finds the largest number