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

  • Home
  • SEARCH
  • 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 9297847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T22:10:27+00:00 2026-06-18T22:10:27+00:00

I am trying to get a specific json response, but one array in the

  • 0

I am trying to get a specific json response, but one array in the response is being passed as an object.

"countries":{"TW":8,"JP":5,"AU":6,"MX":12,"CL":4,"HK":2,"US":14,"AR":4,"ES":1,"BR":1,"MY":9,"IT":12,"DE":1,"GB":1,"PE":6,"TR":1,"KR":3,"IE":1,"CA":2,"FR":1,"VE":2,"IL":1,"PT":1,"NL":1,"PL":1}

But I need it to look like this:

"countries":[["Brazil", 40.5],["US", 30],["Canada", 19.5], ["England", 10]]

How do I build that array in PHP for the json_encode response looks like that?

Now I have:

$countries['US']=14;
$countries['CL']=4;
....

Then I add that array ($countries) to the $data array, which is the one json encoded

$data['countries'] = $countries;

Which gives the result I posted first. But I need that in that in the second format.

Anyone knows what am I missing?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 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-06-18T22:10:28+00:00Added an answer on June 18, 2026 at 10:10 pm
    $countries = Array();
    $countries[] = Array('Brazil', 40.5);
     ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to get a specific value in Python of a JSON object. Before
I'm trying to get specific value by array name: <?php $json = json_decode($_POST['json'], true);
I'm trying to get a specific value from a mysql_fletch_assoc array. I explain. Here
I am trying to get some specific fields out of this Json. I have
Im having some issues when trying to get some Json data into a specific
I am trying to get json data but I am not able to do
I'm trying to link the items from a specific column, but each one will
I am trying to get specific version in git and commit it as the
Im trying to get some checkbox with a specific name document.getElementsByName(test); Unfortunatley i cant
I am trying to get it so that when a specific <li> is clicked,

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.