Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

php
minimum
communitycreator

What is min() in PHP?

Harris Amjad

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

The min() function in PHP returns the minimum value in an array or from a series of values.

The illustration below shows the visual representation of the min() function.

Figure 1: Visual representation of min() function

Syntax

min(value-1, value-2, value-3...value-n)
or 
min(array)

Parameter

The min() function requires either an array or a series of values separated by commas.

Return value

This function returns the minimum value in an array or from a series of values.

Code

<?php
#series of values
echo("min(1,5,3,7,0): ");
echo (min(1,5,3,7,0));
echo("\n");
echo("min(1,-5,3,-7,0): ");
echo (min(1,-5,3,-7,0));
echo("\n");
#array
echo("min(array(-1,-5,-3,-7,0)): ");
echo (min(array(-1,-5,-3,-7,0)));
echo("\n");
echo("min(array(-1,5,-3,7,0)): ");
echo (min(array(-1,5,-3,7,0)));
echo("\n");
?>

RELATED TAGS

php
minimum
communitycreator

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring