note 97120 added to function.max
| From: | grillen at abendstille dot at | Date: | Fri, 02 Apr 2010 11:55:18 +0000 |
| Subject: | note 97120 added to function.max | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-167642@lists.php.net to get a copy of this message | ||
max only accepts not empty arrays.
if you work a lot with numerical arrays and with max, this function may come in handy:
if (!function_exists('emax')) {
function emax($arr) {
if (!is_array($arr)) return call_user_func_array('max', func_get_args());
if (count($arr) == 0) return 0;
return max($arr);
}
}
----
Server IP: 212.124.37.9
Probable Submitter: 217.25.123.250
----
Manual Page -- http://www.php.net/manual/en/function.max.php
Edit -- https://master.php.net/note/edit/97120
Del: integrated -- https://master.php.net/note/delete/97120/integrated
Del: useless -- https://master.php.net/note/delete/97120/useless
Del: bad code -- https://master.php.net/note/delete/97120/bad+code
Del: spam -- https://master.php.net/note/delete/97120/spam
Del: non-english -- https://master.php.net/note/delete/97120/non-english
Del: in docs -- https://master.php.net/note/delete/97120/in+docs
Del: other reasons-- https://master.php.net/note/delete/97120
Reject -- https://master.php.net/note/reject/97120
Search -- https://master.php.net/manage/user-notes.php