note 45941 added to function.array-diff-assoc

From: Date: Fri, 24 Sep 2004 07:41:13 +0000
Subject: note 45941 added to function.array-diff-assoc
Groups: php.notes 
Request: Send a blank email to php-notes+get-77296@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 ;) <?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 ---- Manual Page -- http://www.php.net/manual/en/function.array-diff-assoc.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+45941 Delete -- http://master.php.net/manage/user-notes.php?action=delete+45941&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+45941&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#77296) next »