note 117404 added to function.count
| From: | pied-pierre | Date: | Thu, 04 Jun 2015 17:27:32 +0000 |
| Subject: | note 117404 added to function.count | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-202746@lists.php.net to get a copy of this message | ||
A function of one line to find the number of elements that are not arrays, recursively :
function count_elt($array, &$count=0){
foreach($array as $v) if(is_array($v)) count_elt($v,$count); else ++$count;
return $count;
}
----
Server IP: 195.221.21.36
Probable Submitter: 78.233.252.171
----
Manual Page -- http://php.net/manual/en/function.count.php
Edit -- https://master.php.net/note/edit/117404
Del: integrated -- https://master.php.net/note/delete/117404/integrated
Del: useless -- https://master.php.net/note/delete/117404/useless
Del: bad code -- https://master.php.net/note/delete/117404/bad+code
Del: spam -- https://master.php.net/note/delete/117404/spam
Del: non-english -- https://master.php.net/note/delete/117404/non-english
Del: in docs -- https://master.php.net/note/delete/117404/in+docs
Del: other reasons-- https://master.php.net/note/delete/117404
Reject -- https://master.php.net/note/reject/117404
Search -- https://master.php.net/manage/user-notes.php