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
)
array_count($data)orarray_count($_POST['data'])just give me back a no properties flag. What I am trying to simply do is count the number of sub-arrays in a main array. I have figured out what code works below; my next step is to use that code as the loop in which I will run SQL statements to insert/update a database.array_count($data)orarray_count($_POST['data'])all it shows me in the console is no properties. I have defined@data=$_POST['data']in my code so either should work. when i try to assign$count = array_count($data)and then doecho $count, all I get in browser console is no properties. that's all it says. of course, that's trying to use the method you highlighted. if you read down I did get my end result, so thanks for responding.