note 84482 deleted from function.count by levim

From: Date: Thu, 10 Jan 2013 14:21:51 +0000
Subject: note 84482 deleted from function.count by levim
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-192878@lists.php.net to get a copy of this message
Note Submitter: michael.debyl at gmail dot comz0r ---- 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 :) <?php 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; } ?>

« previous php.notes (#192878) next »