note 66954 added to function.array-sum
| From: | jodymickeyatyahoodotcom at osu1 dot php dot net | Date: | Thu, 01 Jun 2006 15:23:50 +0000 |
| Subject: | note 66954 added to function.array-sum | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-112766@lists.php.net to get a copy of this message | ||
In reference to KageKonjou's array_mode function...
If you only want to know the value in the array that occurs most (and not the number of times it
actually occured), you can use this short function. It also suffers from the same problem in that
if there is more than one mode, it will return only one.
<?php
function array_mode($array)
{
if(!is_array($array)) return false;
asort(array_count_values($array));
return array_pop($array);
}
?>
----
Server IP: 216.194.113.175
Probable Submitter: 64.16.165.197
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.array-sum.php
Edit -- http://master.php.net/note/edit/66954
Del: integrated -- http://master.php.net/note/delete/66954/integrated
Del: useless -- http://master.php.net/note/delete/66954/useless
Del: bad code -- http://master.php.net/note/delete/66954/bad+code
Del: spam -- http://master.php.net/note/delete/66954/spam
Del: non-english -- http://master.php.net/note/delete/66954/non-english
Del: in docs -- http://master.php.net/note/delete/66954/in+docs
Del: other reasons-- http://master.php.net/note/delete/66954
Reject -- http://master.php.net/note/reject/66954
Search -- http://master.php.net/manage/user-notes.php