note 87547 added to function.max
| From: | sumeruter+phpaddanatgmaildotcom at osu1 dot php dot net | Date: | Tue, 09 Dec 2008 23:54:55 +0000 |
| Subject: | note 87547 added to function.max | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-147974@lists.php.net to get a copy of this message | ||
An interesting feature not mentioned is that if a recursive array is passed to max, max will return
the sub-array containing the highest value.
Example:
<?php
$depth3=array(
array(array(1,6,3),array(7,2,5),array(9,3,0)),
array(array(2,1,8),array(4,4,5),array( 99 ,6,7)),
array(array(0,3,2),array(5,91,11),array(42,25,12)));
$depth2=max($depth3);
// = array(array(2,1,8),array(4,4,5),array( 99 ,6,7))
$depth1=max($depth2);
// = array( 99 ,6,7)
$depth0=max($depth1);
// = 99
echo max(max(max($depth3)));
// echo 99;
?>
----
Server IP: 217.160.72.57
Probable Submitter: 85.177.188.12
----
Manual Page -- http://www.php.net/manual/en/function.max.php
Edit -- https://master.php.net/note/edit/87547
Del: integrated -- https://master.php.net/note/delete/87547/integrated
Del: useless -- https://master.php.net/note/delete/87547/useless
Del: bad code -- https://master.php.net/note/delete/87547/bad+code
Del: spam -- https://master.php.net/note/delete/87547/spam
Del: non-english -- https://master.php.net/note/delete/87547/non-english
Del: in docs -- https://master.php.net/note/delete/87547/in+docs
Del: other reasons-- https://master.php.net/note/delete/87547
Reject -- https://master.php.net/note/reject/87547
Search -- https://master.php.net/manage/user-notes.php