First, thank you so much to everyone who responded.
Second, Let me clarify (I posted my question when I should have been in bed, sorry). I want to count the number of arrays in the second dimension of a multidimensional array. I'd like to be able to detect a 3 or more dimensional array and return an error also for cool error handling, but I'm not quiet there yet. The reason for going thru a construct and using func_get_arg is to count the number of args passed in and if the user passes in several single dimensional arrays I can make them into a multidimensional array first. I want, in the end, 1 array, containing 2 or more, 1 dimensional arrays.
vivekanand25: I have not had a chance to try your code yet but I will later this afternoon.
Barand: Nice observation with your array, this at least would return "4" as there are 4 arrays in the 2nd dimension or, ideally, return an error stating that the array is more than 2 dimensional.
$arr=array(
array(1,2,3,4,5,6,7,8,9),
array(1,2,3,4,5,6),
'xyz',
array (
array(1,2),
'abc',
array(3,4)
),
array(1,2,3,4,5,6,7,
);
Also, your "substr_count(print_r($arr,1), 'Array');" code works well. Of course, I have to assume I have a 2D array already but it does good for now. I just substract 1 from the results and Im good to go.
requinix: I experimented with
$counts = array_map("count", $a1);
for a while and was not able to make it work for my purpose but it was still a good experience for meas I did not know about array_map(). Your
return count(array_filter($arr, "is_array"));
works great. Im not sure how to use
count_arrays(array("Array"));
though. I can play with it tonight.
Thank you to everyone again.