How to use php min function?

藏色散人
Release: 2023-02-22 21:56:01
Original
3373 people have browsed it

php The min function is used to return the minimum value in an array, or the minimum value among several specified values. Its syntax is min(array_values). The parameter array_values ​​is required and refers to specifying an array containing values.

How to use php min function?

#How to use php min function?

Definition and usage

min() function returns the minimum value in an array, or the minimum value among several specified values.

Syntax

min(array_values);
or
min(value1,value2,...);
Copy after login

Parameters

array_values ​​Required. Specifies an array containing values.

value1,value2,... Required. Specifies the values ​​to be compared (at least two values).

Return value: Minimum numerical value.

Return type: Mixed

PHP version: 4

Example

Find the minimum value through the min() function:

<?php
echo(min(2,4,6,8,10) . "<br>");
echo(min(22,14,68,18,15) . "<br>");
echo(min(array(4,6,8,10)) . "<br>");
echo(min(array(44,16,81,12)));
?>
Copy after login

Output:

2
14
4
12
Copy after login

The above is the detailed content of How to use php min function?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!