note 45941 deleted from function.array-diff-assoc by aidan
| From: | aidan@php.net | Date: | Sun, 26 Sep 2004 00:13:26 +0000 |
| Subject: | note 45941 deleted from function.array-diff-assoc by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-77330@lists.php.net to get a copy of this message | ||
Note Submitter: Ronald Nuris
----
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 ;)
<?php
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;
}
?>
Ronald Nuris
http://www.nuris.us