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 8942327
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T11:29:18+00:00 2026-06-15T11:29:18+00:00

I have a JSON encoded array that looks like this (it came from a

  • 0

I have a JSON encoded array that looks like this (it came from a 2d PHP string array):

[
[
    "a1",
    "a2",
    "a3",
    "a4"
],
[
    "b1",
    "b2",
    "b3",
    "b4"
],
[
    "c1",
    "c2",
    "c3",
    "c4"
]
]

It has been validated on http://jsonlint.com/

Now I want to send this array to another page by Ajax and convert it back to a 2d PHP array.
After making a JSON array I do the following (where myJsonArray is the name I gave to the array after making it into a Javascript array.:

$.ajax({
       type: "GET",
       url: "somewhere.php",
       data: {jsonArray : myJsonArray},
       dataType: "json",
       success: function(msg){
         alert( msg); 
       }

     });
 }

And then in somewhere.php I do:

 $json_array = $_GET['jsonArray'];

 $myArray = json_decode($json_array,true);

But when I echo the result I just get

[Object object]

I’m not sure how to recreate the PHP array.

EDIT:
How to make myJsonArray:

<?php
$array = json_encode($original_array);

echo "var myJsonArray = ". $array . ";\n";
?>

I would also like to point out that for tesitng purposes, in the alert box I made it print myJsonArray on success, and it did indeed print out the array as expected.

  • 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-15T11:29:19+00:00Added an answer on June 15, 2026 at 11:29 am

    “[Object object]” is javascript evaluating an object as a string.

    When you pass the optional “true” into json_decode, you are telling it that it is an associative array. But you really want an array of arrays.

    I am sure that if you use JSON.stringify to print to your log, you would have the correct data, except the outer brackets would be “{..}”.

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

Sidebar

Related Questions

I have a JSON string (from PHP's json_encode() that looks like this: [{id: 1,
I have a json array in my Particles controller that looks like this after
I have a php file somejson.php that echos a json encoded array {jsonone:first json,jsontwo:second
I have JSON text that looks like this: { ok: true, totalPages: 256, arReports:
I have php function, that returns array to JavaScript like this: $data['first'] = 10;
Okay, so I have an AJAX function that gets a JSON encoded string from
I have a multidimensional array that looks something like this: ourThing = array( 'id'
I have been using JSON objects encoded in PHP from my MySQL database in
I have JSON string that has nested objects with dynamic names that vary each
I know that this question might have been asked like 100 times, but, believe

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.