note 32480 added to function.array-count-values

From: Date: Wed, 28 May 2003 19:58:39 +0000
Subject: note 32480 added to function.array-count-values
Groups: php.notes 
Request: Send a blank email to php-notes+get-49205@lists.php.net to get a copy of this message
I fount a solution for the count of array elements in the sense of array_count_values, but i was not able to use the function array_count_values itself because it does not say me if arrays exists in the given array, so i had to use a foreach loop and a little bit of recursivity ;) function array_count_values_multidim($a,$out=false) { if ($out===false) $out=array(); if (is_array($a)) { foreach($a as $e) $out=array_count_values_multidim($e,$out); } else { if (array_key_exists($a,$out)) $out[$a]++; else $out[$a]=1; } return $out; } ---- Manual Page -- http://www.php.net/manual/en/function.array-count-values.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+32480 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+32480&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+32480&report=yes

« previous php.notes (#49205) next »