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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:00:42+00:00 2026-05-25T14:00:42+00:00

I have a php multidimensional array populated from a table using the following code:

  • 0

I have a php multidimensional array populated from a table using the following code:

<?php starts

$array = array();
$i = 0;

while($row = mysql_fetch_array($result))
{

$array[$i] = array("handle" => $row['handle'],"firstname" => $row['first_name'],"lastname" => $row['last_name']);
$i++;
}

echo json_encode(json_encode($array));

?> php ends

this is called by .post from jQuery and when I alert() the data returned I get the following output:

[
{"handle":"admin","firstname":"admin","lastname":"admin"},
{"handle":"ms","firstname":"ms","lastname":"ms"},
{"handle":"op","firstname":"op","lastname":"op"},
{"handle":"ui","firstname":"ui","lastname":"ui"}
]

the Jquery code I use to extract the php array is:

$.post("test1.php","",
            function(data){

                var obj = $.parseJSON(data);
                alert(obj);
                var obj2 = $.parseJSON(obj);
                alert(obj2);
                alert(obj2[1]);
                var result = eval(data);
                alert(result[0][0]);


    },"html");

alert(obj) gives me the output specified.
alert(obj2) gives me:

[object Object],[object Object],[object Object],[object Object]

alert(obj2[1]) gives me:

[object Object]

How do I get at the data in this???

  • 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-05-25T14:00:43+00:00Added an answer on May 25, 2026 at 2:00 pm

    Your first

    var obj = $.parseJSON(data);
    

    Should be all you need. You can then access your objects like:

    obj[0]['handle']
    // or
    obj[0].handle
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's assume I have the following multidimensional array (retrieved from MySQL or a service):
I have a PHP class that stores a complex multidimensional array, and rather than
I have a php multidimensional array (2 levels) with some values and I want
I have a massive multidimensional array that has been serialised by PHP. It has
i have a multidimensional array. the array is returned by parsing xml using curl.
How can I convert text file into multidimensional array using php? For example I
How do I form a multidimensional array using MySQL data? I'm using this code
i have this multidimensional array in php and I need be able to access
I have a php multidimensional array which looks like this: $fields = array( array('input',
Possible Duplicate: PHP Sort a multidimensional array by element containing date I have some

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.