note 75737 added to function.count

From: Date: Wed, 13 Jun 2007 20:14:43 +0000
Subject: note 75737 added to function.count
Groups: php.notes 
Request: Send a blank email to php-notes+get-127458@lists.php.net to get a copy of this message
I actually find the following function more useful when it comes to multidimension arrays when you do not want all levels of the array tree. // $limit is set to the number of recursions <?php function count_recursive ($array, $limit) { foreach ($array as $id => $_array) { if (is_array ($_array) && $limit > 0) $count += count_recursive ($_array, $limit - 1); else $count += 1; } return $count; } ?> ---- Server IP: 212.199.163.191 Probable Submitter: 88.155.208.9 ---- Manual Page -- http://www.php.net/manual/en/function.count.php Edit -- https://master.php.net/note/edit/75737 Del: integrated -- https://master.php.net/note/delete/75737/integrated Del: useless -- https://master.php.net/note/delete/75737/useless Del: bad code -- https://master.php.net/note/delete/75737/bad+code Del: spam -- https://master.php.net/note/delete/75737/spam Del: non-english -- https://master.php.net/note/delete/75737/non-english Del: in docs -- https://master.php.net/note/delete/75737/in+docs Del: other reasons-- https://master.php.net/note/delete/75737 Reject -- https://master.php.net/note/reject/75737 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#127458) next »