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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T00:49:01+00:00 2026-05-22T00:49:01+00:00

I have a complicated structure of returned by an URL in JSON format, i

  • 0

I have a complicated structure of returned by an URL in JSON format, i have got the reponse which I can view through var_dump, Now I have this reponse,

{
  "groups": [],
  "total_pages": 1,
  "spots": [
    {
      "address": {
        "region": "TX",
        "locality": "Austin"
      },
      "name": "Dirty Bill's",
      "checkins_count": 646,
      "_image_url_200": "http://static.gowalla.com/categories/28-b0d41920d32839ce1ecd6641e5fc2c87-200.png",
      "image_url": "http://static.gowalla.com/categories/28-78c9b4d7d239784df49dc932f64a3519-100.png",
      "_image_url_50": "http://static.gowalla.com/categories/28-78c9b4d7d239784df49dc932f64a3519-100.png",
      "radius_meters": 50,
      "trending_level": 0,
      "users_count": 375,
      "url": "/spots/43711",
      "checkins_url": "/checkins?spot_id=43711",
      "lng": "-97.7495040214",
      "spot_categories": [
        {
          "name": "Dive Bar",
          "url": "/categories/28"
        }
      ],
      "foursquare_id": null,
      "highlights_url": "/spots/43711/highlights",
      "items_url": "/spots/43711/items",
      "items_count": 11,
      "strict_radius": false,
      "description": "AKA the Gnome Bar. Much Warmer than Key Bar.",
      "activity_url": "/spots/43711/events",
      "lat": "30.2696322356",
      "photos_count": 23
    },
    {
      "address": {
        "region": "TX",
        "locality": "Austin"
      },
      "name": "Austin Wellness Clinic",
      "checkins_count": 1,
      "_image_url_200": "http://static.gowalla.com/categories/118-b41c2ba96f1ffe99fc23f12f0ee3b960-200.png",
      "image_url": "http://static.gowalla.com/categories/118-5f9e72162abf3dcbc0108cdbdba6a29f-100.png",
      "_image_url_50": "http://static.gowalla.com/categories/118-5f9e72162abf3dcbc0108cdbdba6a29f-100.png",
      "radius_meters": 75,
      "trending_level": 0,
      "users_count": 1,
      "url": "/spots/7360448",
      "checkins_url": "/checkins?spot_id=7360448",
      "lng": "-97.7495133877",
      "spot_categories": [
        {
          "name": "Health & Fitness",
          "url": "/categories/118"
        }
      ],
      "foursquare_id": null,
      "highlights_url": "/spots/7360448/highlights",
      "items_url": "/spots/7360448/items",
      "items_count": 0,
      "strict_radius": false,
      "description": null,
      "activity_url": "/spots/7360448/events",
      "lat": "30.2695755256",
      "photos_count": 0
    },

I have used json_decode($response,true) to get a parse variable, now I am not sure as to how to loop through it. Any ideas?!

edit 1: The spots is an array[] which has an index 0. I want to loop though each name valu pair inside the spots array

  • 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-22T00:49:01+00:00Added an answer on May 22, 2026 at 12:49 am
    <?php
    
    $json = json_encode(
        array(
            'spots' => array(
                'bar' => 'baz',
                array(
                    'quz' => 'foo',
                    'bar' => 'baz'
                )
            )
        )
    );
    
    $root = json_decode( $json, true );
    
    function read( $array ) {
        foreach( (array) $array as $key => $value ) {
            if( is_array( $value ) ) {
                read( $array );
            }
            echo "$key = $value\n";
        }
    }
    
    foreach( $root['spots'] as $spot ) {
        read( $spot );
    }
    

    This should give you all the information inside the spot array.

    EDIT: Now with actually checked syntax, it works.

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

Sidebar

Related Questions

I have a complicated MySQL query which takes a lot of time, selecting from
I have some complicated, problem to be solved. Now I need to write such
I've got a program where a lot of classes have really complicated configuration requirements.
Im having a very strange problem, i have a complicated view that returns incorrect
I have a complicated structure where I have a custom tab-bar controller that houses
I have a bit of a complicated structure that I have listed below. Basically
I have a complicated structure to be displayed on the screen. Made with XML
Given a scenario: I have my own system's object structure. Now there are more
I have this complicated structure thingie: #include <stdlib.h> typedef struct { int x; int
I have a somewhat complicated branching structure at work (at least for me). It

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.