ID: 37949 Updated by: [EMAIL PROTECTED] Reported By: delta407 at lerfjhax dot com -Status: Open +Status: Bogus Bug Type: *General Issues Operating System: Linux PHP Version: 5.1.4 New Comment:
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php This is expected. Previous Comments: ------------------------------------------------------------------------ [2006-06-28 15:39:12] delta407 at lerfjhax dot com Description: ------------ max() throws a warning when given an empty array. The documentation reads: "If the first and only parameter is an array, max() returns the highest value in that array. ... You can compare an unlimited number of values." "Unlimited number of values", by definition of unlimited, includes zero values. (If there aren't any values in the array, the highest value is the value null.) This is consistent with other max() implementations -- MySQL, Oracle, Postgres, Ruby... Please either remove the warning and return null, or update the documentation to reflect the existence of the warning. Reproduce code: --------------- <? $a = array(1,3,2); function foo() { global $a; $v = max($a); echo is_null($v) ? "(null)\n" : "$v\n"; array_pop($a); } foo($a); foo($a); foo($a); foo($a); ?> Expected result: ---------------- 3 3 1 (null) Actual result: -------------- 3 3 1 PHP Warning: max(): Array must contain atleast one element in foo.php on line 6 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=37949&edit=1