Backend Development 2 min read

PHP min() Function: Finding the Minimum Value

This article explains how PHP's min() function determines the smallest value, detailing its behavior with single array arguments versus multiple scalar arguments, describing parameters and return values, and providing clear code examples for common use cases.

Laravel Tech Community
Laravel Tech Community
Laravel Tech Community
PHP min() Function: Finding the Minimum Value

The min() function in PHP returns the smallest value among its arguments. When a single array is passed, it returns the minimum element of that array; with multiple arguments, it compares them and returns the smallest.

Parameters

mixed $values – an array of values, or multiple comparable values ( $value1 , $value2 , ...).

Return value

Returns the lowest value among the provided arguments. If arrays are compared, they are considered larger than scalar values.

Examples

When mixing arrays and scalars, arrays are treated as larger, so the function returns the scalar minimum.

BackendArraymin functionvalue comparison
Laravel Tech Community
Written by

Laravel Tech Community

Specializing in Laravel development, we continuously publish fresh content and grow alongside the elegant, stable Laravel framework.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.