CKTIS / PHP
min()
Use min on one nonempty array to obtain its smallest value, or pass two or more individual candidates.
Version: PHP 8.4; repository runtime, production runtime not attested
Syntax
min(mixed $value, mixed ...$values): mixedUse min on one nonempty array to obtain its smallest value, or pass two or more individual candidates. PHP comparisons retain the selected value’s type. In the verified PHP 8.4.27 runtime the tie between 3 and the string "3" yields int in the array form but string for the direct two-argument call. Array keys do not participate when selecting among the values of one array. A single empty array raises ValueError.
Signature
min(mixed $value, mixed ...$values): mixed
Example output
[-4,"string","int",1]
ValueError
Examples
<?php
$tie = min(3, "3");
$arrayTie = min([3, "3"]);
echo json_encode([min(["z" => -4, "a" => 7]), get_debug_type($tie), get_debug_type($arrayTie), min(4, 7, 1)]), PHP_EOL;
try { min([]); } catch (ValueError $e) { echo get_class($e); }
Result
[-4,"string","int",1] ValueError