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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:24:05+00:00 2026-06-13T22:24:05+00:00

JSON [ { kind: Listing }, { kind: Listing, data: { children: [ {

  • 0

JSON

[
  {
    "kind": "Listing"
  },
  {
    "kind": "Listing",
    "data": {
      "children": [
        {
          "data": {
            "body": "body1"
          }
        },

        {
          "data": {
            "body": "body2"
          }
        }
      ]
    }
  }
]

The parts I want to loop through: [{first set of values},{data->children->data->body}

That last body is the part I want to grab. There are multiple other sets of those, each “body” represents a seperate comment without children on reddit.

  • 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-13T22:24:06+00:00Added an answer on June 13, 2026 at 10:24 pm

    json_decode the json into an object and then loop:

    <?php 
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "http://www.reddit.com/r/indie/comments/zc0lz/.json");
    curl_setopt($curl, CURLOPT_HEADER, 0);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($curl, CURLOPT_TIMEOUT, 30);
    $json = curl_exec($curl);
    curl_close($curl);
    //decode the json
    $json_obj = json_decode($json);
    //loop the result set(array) and access the data->children sub array.
    foreach($json_obj as $v){
        foreach($v->data->children as $d){
            if(isset($d->data->body)){
                echo $d->data->body.'<br />'.PHP_EOL;
            }
        }
    }
    
    /*
    Is anyone else bored with this? The first album was good for the moment it existed in, but the has since passed. It just seems their sound didn't mature very well.<br />
    Yeah, from the songs I had heard, this album missed it. Too similar and not as exciting.<br />
    half the album is just as amazing as the first. half is kind of dull<br />
    Got this album today, maybe 2 decent-ish songs, but it sounds like they have tried to copy some of the sounds from the album way too closely. Real shame. 4/10<br />
    If the player doesn't work, refresh the page and try again. You can also use the NPR link!<br />
    Loved the sound of the first album, and I'm kind of happy they've not strayed to much away from this. Have to agree that it seems to be missing the 'awesomeness' that made the first songs so enjoyable to listen to.<br />
    */
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to be able to Ajax-ly retrieve JSON data from some kind of
I used to have this kind of simple JSON data and I could successfully
I have following kind of index while accessing json data using jquery data.rows[0].student_1 data.rows[0].student_2
well I receive this kind of JSON data from an external server {'mydata':[{'id':1012, 'username':'foo',
Is there some kind a engine for Json in the Zend framework, What I
sendng json data to another jsp page - for testing really. You enter a
There is a json data: var json = { entry : [{ category :
Greetings kind community of wise developers !! It's my first time writing and I've
I have a piece of code that encodes some kind of business data in
Pls how do I retrieve the title from this json usng PHP { kind:

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.