i need to count a multidimensional array, but with some rules.
My array is this:
<?$array[$iddom][$idrisp][$idopt][$iddoc][$idut]=$text;?>
and i have for example this values:
[1][1][0][0][31248]=
[1][1][0][0][46619]=
[2][4][0][0][31248]=
[2][5][0][0][46619]=
[3][6][1][0][31248]=
[3][6][3][0][46619]=
[3][7][3][0][31248]=
[3][7][2][0][46619]=
[3][8][1][0][31248]=
[3][8][1][0][46619]=
[4][9][0][0][46619]=
[4][11][0][0][31248]=
[5][13][5][0][31248]=
[5][13][6][0][46619]=
[5][14][4][0][31248]=
[5][14][4][0][46619]=
[5][15][6][0][31248]=
[5][15][5][0][46619]=
[6][0][7][6][31248]=
[6][0][7][6][46619]=
if i want to count only a part of array, i use this code:
<?$count=array_sum(array_map("count", $array[$key]));?>
in this case count is correct
[2][4][0][0][31248]=
[2][5][0][0][46619]=
the result of count is 2
but in this case the result is 1
[1][1][0][0][31248]=
[1][1][0][0][46619]=
how i can count dinamically arrays multidimensional? because in anothe case i need to count for example another level of array, like this:
<?$count=array_sum(array_map("count", $array[$key][$key2]));?>
thanks