note 84482 added to function.count

From: Date: Wed, 16 Jul 2008 10:45:03 +0000
Subject: note 84482 added to function.count
Groups: php.notes 
Request: Send a blank email to php-notes+get-141561@lists.php.net to get a copy of this message
There doesn't seem to be a succinct method already noted on this page for counting multidimensional array end nodes (Items in multidimensional arrays), so I thought this function might help somebody. Nice and simple :) function rcount ($array) { $count = 0; if (is_array($array)) { foreach($array as $id=>$sub) { if (!is_array($sub)) { $count++; } else { $count = ($count + rcount($sub)); } } return $count; } return FALSE; } ---- Server IP: 69.147.83.197 Probable Submitter: 203.217.85.15 ---- Manual Page -- http://www.php.net/manual/en/function.count.php Edit -- https://master.php.net/note/edit/84482 Del: integrated -- https://master.php.net/note/delete/84482/integrated Del: useless -- https://master.php.net/note/delete/84482/useless Del: bad code -- https://master.php.net/note/delete/84482/bad+code Del: spam -- https://master.php.net/note/delete/84482/spam Del: non-english -- https://master.php.net/note/delete/84482/non-english Del: in docs -- https://master.php.net/note/delete/84482/in+docs Del: other reasons-- https://master.php.net/note/delete/84482 Reject -- https://master.php.net/note/reject/84482 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#141561) next »