Counting rows/records in a multidimensional array

I have a set of nested arrays.

[data] is the top level array.

The lower level arrays are all identified by incremental numbers, dynamically assigned...essentially each sub-array identifies a row/record of information.

How would I extract the count of the sub-arrays? I need to be able to do this to post this data into a DB.

The number of sub-arrays is dynamic, and can change depending on what data I am parsing through.

 [data] => Array
        (
            [0] => Array
                (
                    [id] => 3475
                    [name] => Player1
                    [score] => 11870
                    [rank] => 213
                    [total_cities] => 2
                    [crown] => None
                    [alliance_id] => 134
                    [title] => Earl
                    [fame_total] => 509875
                    [fame_rank] => 381
                    [defeated_total] => 3436
                    [defeated_rank] => 376
                    [plunder_total] => 1388754
                    [plunder_rank] => 245
                )

            [1] => Array
                (
                    [id] => 3523
                    [name] => Player2
                    [score] => 1978
                    [rank] => 281
                    [total_cities] => 1
                    [crown] => None
                    [alliance_id] => 134
                    [title] => Baron
                    [fame_total] => 0
                    [fame_rank] => 448
                    [defeated_total] => 0
                    [defeated_rank] => 448
                    [plunder_total] => 0
                    [plunder_rank] => 436
                )

            [2] => Array
                (
                    [id] => 73
                    [name] => Player3
                    [score] => 1308
                    [rank] => 304
                    [total_cities] => 1
                    [crown] => None
                    [alliance_id] => 134
                    [title] => Marquess
                    [fame_total] => 5604153
                    [fame_rank] => 237
                    [defeated_total] => 37270
                    [defeated_rank] => 229
                    [plunder_total] => 68130
                    [plunder_rank] => 335
                )


ANSWERS:


I used a combination of the methods highlighted by Marc B and Thanos to get my desired result

This is the code I used:

$count = 0;
foreach($data as $data=>$inner_array){
   $count = $count+1;
}

echo $count;

I ran it with a test data set with 143 unique rows, and I got that echo back, so life is good.

Thanks guys.


Simplest method:

$count = 0;
foreach($mainarray as $subarray)
   $count += count($subarray);
}

Let's assume $data is your main array: This one prints the name of each inner array (0, 1, 2... for your example) and then counts each sub-array items:

echo "Number of sub-arrays: ".count($online_time); //optional
foreach($data as $inner_array=>$data_of_inner_array) {
echo $inner_array;
echo " --- ".count($data_of_inner_array);
echo "<br/>";
}

i assume output will be

Number of sub-arrays: 3
0 --- 14
1 --- 14
2 --- 14


 MORE:


 ? Php dynamic array name
 ? Get select option value from forms using jquery created dynamically in loop
 ? Get select option value from forms using jquery created dynamically in loop
 ? Get select option value from forms using jquery created dynamically in loop
 ? How do I create a dynamic form in Drupal 6 using jQuery?
 ? How do I get the data from forms dynamically created with jQuery into php?
 ? Dynamically selecting Dropdown's options
 ? jquery trigger button click, and get value of dynamic select/option
 ? Can't get value of select field in a form with jquery
 ? How to set readonly property to false on multiple textboxes with same class?