note 124263 added to function.count
| From: | Anonymous@php.net | Date: | Sat, 05 Oct 2019 05:52:20 +0000 |
| Subject: | note 124263 added to function.count | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-212456@lists.php.net to get a copy of this message | ||
For a Non Countable Objects
$count = count($data);
print "Count: $count\n";
Warning: count(): Parameter must be an array or an object that implements Countable in example.php
on line 159
#Quick fix is to just cast the non-countable object as an array..
$count = count((array) $data);
print "Count: $count\n";
Count: 250
----
Server IP: 208.43.231.9
Probable Submitter: 82.199.157.54 (proxied: 73.22.78.74)
----
Manual Page -- http://php.net/manual/en/function.count.php
Edit -- https://master.php.net/note/edit/124263
Del: integrated -- https://master.php.net/note/delete/124263/integrated
Del: useless -- https://master.php.net/note/delete/124263/useless
Del: bad code -- https://master.php.net/note/delete/124263/bad+code
Del: spam -- https://master.php.net/note/delete/124263/spam
Del: non-english -- https://master.php.net/note/delete/124263/non-english
Del: in docs -- https://master.php.net/note/delete/124263/in+docs
Del: other reasons-- https://master.php.net/note/delete/124263
Reject -- https://master.php.net/note/reject/124263
Search -- https://master.php.net/manage/user-notes.php