Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3306764
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T21:19:38+00:00 2026-05-17T21:19:38+00:00

Now I know there is some related questions on this topic but this is

  • 0

Now I know there is some related questions on this topic but this is somewhat unique.

I have two array structures :

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'
        )
    )

and the second

array(
    'stat1' => array(
        'countries' => array(
            'United States' => 50,
            'Ireland' => 40,
            'Autralia' => 108,
            )
        )
    ),
'stat2' => array(
        'countries' => array(
            'United States' => 12,
            'Ireland' => 38,
            )
        )
    ),
etc...

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 json_encode() 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?

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T21:19:39+00:00Added an answer on May 17, 2026 at 9:19 pm

    I have done some testing and for a finite dataset the difference in the output data – (I outputted the data into a text file) between the two is insignificant really.

    Array structure 1 – All city and country data outputs to 68kb

    Array structure 2 – All city and country data outputs to 71kb

    So there is a slight difference but it seems that the difference is insignificantly small when taking into account that the data is in JSON format and used in an AJAX request to the google visualization geomap API.

    I haven’t tested the micro times in loading difference but for a user to look at a loading .gif image for 0.0024microseconds (i’m shooting a random time for the sake of argument) does not make a big dent in usability either way. Thanx all for you comments

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Note : I know there are many questions related to this, but still I
there are related questions like smart pointers + "this" considered harmful? but they do
There were few questions related to this but none answered the question in my
I have two related questions. First, i have a some information such as: (732,
I know there are many questions related to shared libraries on Linux but maybe
Possible Duplicate: UIDevice uniqueIdentifier Deprecated - What To Do Now? I know there have
All right, do not get angry now, I know there are several questions about
Now i know to use the method of float.Parse but have bumped into a
Sorry for asking this question, but I searched all Java-related questions, but I got
There are several questions throughout this post all related to the title. The overall

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.