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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T18:09:15+00:00 2026-05-29T18:09:15+00:00

My question: How can I break up and iterate through the JSON array pictured

  • 0

My question: How can I break up and iterate through the JSON array pictured below?

I am making an AJAX web app and I need to serialize an array of objects in Javascript and put them in a url to pass to a php script. This is all going fine and the php script recieves the JSON like so..

$passed = $_GET['result']; 
if(isset($passed)){

$passed = str_replace("undefined" , " " , $passed); /*had to add this to remove the undefined value*/

$json = json_decode(stripslashes($passed));
echo"<br/>";
var_dump($json ); //this is working and dumps an array
}

When I call var_dump on the decoded JSON I echo an output like so…

array(1) { [0]=> object(stdClass)#70 (2) { ["itemCount"]=> int(0) ["ItemArray"]=> array(2) { [0]=> object(stdClass)#86 (6) { ["itemPosition"]=> int(0) ["planPosition"]=> int(0) ["Name"]=> string(5) "dsfsd" ["Description"]=> string(3) "sdf" ["Price"]=> string(0) "" ["Unit"]=> string(0) "" } [1]=> object(stdClass)#85 (6) { ["itemPosition"]=> int(1) ["planPosition"]=> int(0) ["Name"]=> string(4) "fdad" ["Description"]=> string(3) "sdf" ["Price"]=> string(0) "" ["Unit"]=> string(0) "" } } } }

The JSON
This is the JSON I am receiving. It seems like some of the pairs don’t have names? How can I access elements in this Array?

Thanks alot guys

The Json I would like to parse in PHP

  • 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-29T18:09:16+00:00Added an answer on May 29, 2026 at 6:09 pm

    Some of these elements are coming back as stdClass objects as you can see in the var_dump output. You can get at the attributes with the standard object notation, for example, with your $json variable:

    echo $json[0]->itemCount; // 0
    echo $json[0]->itemArray[0]->itemPostion; // 0
    

    You can also iterate over stdClass instances just like any PHP object, you’ll be looping through the public data members, so again with your $json:

    foreach(echo $json[0]->itemArray[0] as $key => $value)
      echo 'key: ' . $key . ', value: ' . $value . PHP_EOL;
    

    will loop through that first object, echoing out the member names and values of the object.

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

Sidebar

Related Questions

I had a previous question can jquery ajax call external webservice? and some good
I am using LispBox on MacOSX. My question is, how can I break a
Question Can I build a image database/library that has an e-commerce style checkout system
Simple question: Can a swing frame be completely modal ( block all others windows
Simple question: Can I mix in my desktop application Java and JavaFX Script code?
this question can create a misunderstanding: I know I have to use CSS to
My question can be boiled down to, where does the string returned from stringstream.str().c_str()
Here is the question: Can TortoiseSvn work on Windows 2008 without turning off User
My original question can be found here , for which I've gotten some great
Right bit of a simple question can I input nText into a pivot table?

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.