note 108623 deleted from function.count by salathe
| From: | salathe@php.net | Date: | Fri, 11 May 2012 12:35:46 +0000 |
| Subject: | note 108623 deleted from function.count by salathe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-187939@lists.php.net to get a copy of this message | ||
Note Submitter: kemal dot delalic at gmail dot com
----
Since anything else than array / Countable makes no sense in this function, here's a
"fixed" version:
class arr {
public static function count($array, $mode = COUNT_NORMAL)
{
// Definitely an array
if (is_array($array))
return count($array, $mode);
// Countable
if (is_object($array) AND $array instanceof Countable)
return count($array, $mode);
return NULL;
}
}
This allows
if (arr::count(FALSE) > 0) to evaluate to FALSE.