Unix and Linux Discussions Tagged with min |
|
Thread / Thread Starter |
Last Post |
Replies |
Views |
Forum |
|
|
|
1 |
7,004 |
Cybersecurity |
|
|
|
0 |
2,602 |
UNIX for Beginners Questions & Answers |
|
|
|
11 |
28,929 |
Shell Programming and Scripting |
|
|
|
1 |
3,543 |
Homework & Coursework Questions |
|
|
|
4 |
2,613 |
Programming |
|
|
|
0 |
946 |
Software Releases - RSS News |
|
|
|
0 |
3,359 |
Red Hat |
|
|
|
0 |
1,129 |
UNIX and Linux RSS News |
|
|
|
0 |
1,168 |
UNIX and Linux RSS News |
|
|
|
0 |
1,055 |
Software Releases - RSS News |
|
|
|
0 |
887 |
Software Releases - RSS News |
|
|
|
0 |
1,509 |
UNIX and Linux RSS News |
|
|
|
0 |
1,007 |
UNIX and Linux RSS News |
|
|
|
3 |
4,459 |
Programming |
|
|
|
3 |
2,741 |
UNIX for Dummies Questions & Answers |
|
|
|
4 |
31,115 |
UNIX for Advanced & Expert Users |
|
|
|
4 |
21,839 |
UNIX for Dummies Questions & Answers |
|
|
|
3 |
2,465 |
UNIX for Dummies Questions & Answers |
|
|
|
2 |
3,386 |
Post Here to Contact Site Administrators and Moderators |
|
|
|
4 |
9,777 |
Cybersecurity |
|
|
|
7 |
13,250 |
UNIX for Dummies Questions & Answers |
|
|
|
2 |
2,894 |
UNIX for Dummies Questions & Answers |
MIN(3) 1 MIN(3)
min - Find lowest value
SYNOPSIS
mixed min (array $values)
DESCRIPTION
mixed min (mixed $value1, mixed $value2, [mixed $...])
If the first and only parameter is an array, min(3) returns the lowest value in that array. If at least two parameters are provided,
min(3) returns the smallest of these values.
Note
Values of different types will be compared using the standard comparison rules. For instance, a non-numeric string will be com-
pared to an integer as though it were 0, but multiple string values will be compared alphanumerically. The actual value returned
will be of the original type with no conversion applied.
PARAMETERS
o $values
- An array containing the values.
o $value1
- Any comparable value.
o $value2
- Any comparable value.
o $...
- Any comparable value.
RETURN VALUES
min(3) returns the parameter value considered "lowest" according to standard comparisons. If multiple values of different types evaluate as
equal (e.g. 0 and 'abc') the first provided to the function will be returned.
EXAMPLES
Example #1
Example uses of min(3)
<?php
echo min(2, 3, 1, 6, 7); // 1
echo min(array(2, 4, 5)); // 2
// The string 'hello' when compared to an int is treated as 0
// Since the two values are equal, the order they are provided determines the result
echo min(0, 'hello'); // 0
echo min('hello', 0); // hello
// Here we are comparing -1 < 0, so -1 is the lowest value
echo min('hello', -1); // -1
// With multiple arrays of different lengths, min returns the shortest
$val = min(array(2, 2, 2), array(1, 1, 1, 1)); // array(2, 2, 2)
// Multiple arrays of the same length are compared from left to right
// so in our example: 2 == 2, but 4 < 5
$val = min(array(2, 4, 8), array(2, 5, 1)); // array(2, 4, 8)
// If both an array and non-array are given, the array is never returned
// as comparisons treat arrays as greater than any other value
$val = min('string', array(2, 5, 7), 42); // string
// If one argument is NULL or a boolean, it will be compared against
// other values using the rule FALSE < TRUE regardless of the other types involved
// In the below examples, both -10 and 10 are treated as TRUE in the comparison
$val = min(-10, FALSE, 10); // FALSE
$val = min(-10, NULL, 10); // NULL
// 0, on the other hand, is treated as FALSE, so is "lower than" TRUE
$val = min(0, TRUE); // 0
?>
SEE ALSO
max(3), count(3).
PHP Documentation Group MIN(3)