note 106184 added to function.key
| From: | FatBat at osu1 dot php dot net | Date: | Mon, 17 Oct 2011 19:20:50 +0000 |
| Subject: | note 106184 added to function.key | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-183939@lists.php.net to get a copy of this message | ||
Needed to get the index of the max/highest value in an assoc array.
max() only returned the value, no index, so I did this instead.
<?php
reset($x); // optional.
arsort($x);
$key_of_max = key($x); // returns the index.
?>
----
Server IP: 64.71.164.2
Probable Submitter: 64.197.126.226
----
Manual Page -- http://www.php.net/manual/en/function.key.php
Edit -- https://master.php.net/note/edit/106184
Del: integrated -- https://master.php.net/note/delete/106184/integrated
Del: useless -- https://master.php.net/note/delete/106184/useless
Del: bad code -- https://master.php.net/note/delete/106184/bad+code
Del: spam -- https://master.php.net/note/delete/106184/spam
Del: non-english -- https://master.php.net/note/delete/106184/non-english
Del: in docs -- https://master.php.net/note/delete/106184/in+docs
Del: other reasons-- https://master.php.net/note/delete/106184
Reject -- https://master.php.net/note/reject/106184
Search -- https://master.php.net/manage/user-notes.php