note 29159 rejected from function.count by tularis

From: Date: Tue, 04 Feb 2003 18:25:42 +0000
Subject: note 29159 rejected from function.count by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-43406@lists.php.net to get a copy of this message
This is a function to count the arrays in a multimensional array. // -> $counter = 0; function count_subarrays(&$val, &$key, &$counter) { if (is_array($val)) { $counter++; array_walk (&$val, 'count_subarrays', &$counter); } } array_walk ($array, 'count_subarrays', &$counter); echo ($counter); // <- If you want to count all elements just move the "$counter++;" outside the if.

« previous php.notes (#43406) next »