Okay, you want all of them totalled across the whole two-dimensional array?
I'd replace the for($i...) with a pair of nested foreach()es and do the counting manually.
$count=0;
foreach($array as $row)
{
foreach($row as $name)
++$countednames[$name];
++$count
}
}
Now arrays with arbitrary numbers of dimensions might need a bit more work. Probably best done as a recursive function built around a single foreach loop; each array element is checked and if it is itself an array, the function calls itself, otherwise it does the ++ ++ bit.
function recursive_totals($array,&$countednames,&$count)
{
foreach($array as $item)
if(is_array($item))
{
recursive_totals($item,$countednames,$count);
}
else
{++$countednames[$item];
++$count;
}
}
(Totally untested code!)
...and call it with:
unset($countednames);
recursive_totals($array,$countednames);
recursive_totals($array)
PS: You're welcome!