PHP: How will array depth influence performance?

seanhongkong

New Member
Now I know there is some related questions on this topic but this is somewhat unique.I have two array structures :\[code\]array( [0] => array( 'stat1' => 50, 'stat2' => 12, 'stat3' => 0, 'country_name' => 'United States' ), [1] => array( 'stat1' => 40, 'stat2' => 38, 'stat3' => 15, 'country_name' => 'Ireland' ), [2] => array( 'stat1' => 108, 'stat2' => 0, 'stat3' => 122, 'country_name' => 'Autralia' ) )\[/code\]and the second \[code\]array( 'stat1' => array( 'countries' => array( 'United States' => 50, 'Ireland' => 40, 'Autralia' => 108, ) ) ),'stat2' => array( 'countries' => array( 'United States' => 12, 'Ireland' => 38, ) ) ),etc...\[/code\]The second array can go even to level 4 or 5 if you add the cities of those respective countries. Further to note is that the second array structure will have no 0 data fields (note that in the second one australia is not there because it is 0) but the first structure will have a whole whack of zeros. Also note that the second structure will have duplicates i.e. 'United States'My question is this: How does these array structures compare when they are \[code\]json_encode()\[/code\] and used in a POST ajax request? Will the shallow depth array, with it's whack of zeros be faster or will the better structured array be better in terms of size?
 
Back
Top