note 53474 added to function.max
| From: | walkingmantis at osu1 dot php dot net | Date: | Thu, 02 Jun 2005 15:20:56 +0000 |
| Subject: | note 53474 added to function.max | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-89802@lists.php.net to get a copy of this message | ||
To find the max value of a multidimensional array, use max(max())
Use as many max()'s as there are dimensions
2D array
Input:
<?php
$a1 = range(1,25);
$a2 = range(26,50);
$a3 = range(51,75);
$a4 = range(76,100);
$a = array($a1,$a2,$a3,$a4);
echo $aMax = max(max($a));
?>
Output:
100
3D array
Input:
<?php
$a1 = range(1,25);
$a2 = range(26,50);
$a3 = range(51,75);
$a4 = range(76,100);
$a = array($a1,$a2,$a3,$a4);
$aA = array($a,$a);
echo $aMax = max(max(max($aA)));
?>
Output:
100
etc.
----
Manual Page -- http://www.php.net/manual/en/function.max.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+53474
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+53474&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+53474&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+53474&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+53474&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+53474&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+53474&report=yes
Search -- http://master.php.net/manage/user-notes.php