note 76199 added to function.max
| From: | michaelangel0atmail dot com at osu1 dot php dot net | Date: | Wed, 04 Jul 2007 22:00:34 +0000 |
| Subject: | note 76199 added to function.max | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-128231@lists.php.net to get a copy of this message | ||
Matlab users and others may feel lonely without the double argument output from min and max
functions.
To have the INDEX of the highest value in an array, as well as the value itself, use the following,
or a derivative:
<?
function doublemax($mylist){
$maxvalue=max($mylist);
while(list($key,$value)=each($mylist)){
if($value==$maxvalue)$maxindex=$key;
}
return array("m"=>$maxvalue,"i"=>$maxindex);
}
?>
----
Server IP: 194.145.210.4
Probable Submitter: 82.3.208.78
----
Manual Page -- http://www.php.net/manual/en/function.max.php
Edit -- https://master.php.net/note/edit/76199
Del: integrated -- https://master.php.net/note/delete/76199/integrated
Del: useless -- https://master.php.net/note/delete/76199/useless
Del: bad code -- https://master.php.net/note/delete/76199/bad+code
Del: spam -- https://master.php.net/note/delete/76199/spam
Del: non-english -- https://master.php.net/note/delete/76199/non-english
Del: in docs -- https://master.php.net/note/delete/76199/in+docs
Del: other reasons-- https://master.php.net/note/delete/76199
Reject -- https://master.php.net/note/reject/76199
Search -- https://master.php.net/manage/user-notes.php