note 88475 deleted from function.max by thiago
| From: | thiago@php.net | Date: | Mon, 26 Jan 2009 15:36:27 +0000 |
| Subject: | note 88475 deleted from function.max by thiago | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-149779@lists.php.net to get a copy of this message | ||
Note Submitter: int at mage dot ich
----
To sumeruter+php add an at gmail dot com: This is not functional for all arrays - not always is
returned the highest value. For example:
<?php
$array = Array (
"first" => Array(
0 => 19,
1 => 41,
2 => 7,
3 => 21,
4 => 32,
),
"second" => Array (
0 => 8,
1 => 84,
2 => 63,
3 => 61,
4 => 100,
));
ECHO max(max($array)); // = 41
?>
It will return 41 instead of expected 100. It's because the array is compared from left to
right, as is written in manual:
$array["first"][0] > $array["second"][0] ? RETURN
$array["first"][0] : RETURN $array["second"][0]
Which sub-array is returned depends only on the first values of them.