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

  • Home
  • SEARCH
  • 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 8321957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T23:12:17+00:00 2026-06-08T23:12:17+00:00

I am having a hard time working with nested arrays using json_decode(). I am

  • 0

I am having a hard time working with nested arrays using json_decode(). I am trying to get a list of team names.

Here is the actual array: http://pastebin.com/eMqMcucN

If you look at the array, there are three teams. The first team contains data I do not need and is not complete (but I am able to get the team name). Its the nested array where teams have complete data thats getting me. What I would like to get is the two additional team names and ignore the first team as it has no nested arrays and no real details. However, I have no problem geting the first team name as it is not nested.

Any help/direction would be greatly appreciated. Here is what I am currently using on the array above.

The line “echo ‘name: ‘ . $sd->name;” throws an error of “Warning: Invalid argument supplied for foreach()”. I have tried variations but no luck.

$obj=json_decode($json);
$data = $obj->fantasy_content->users->{'0'}->user[1]->teams;
$userguid = $obj->fantasy_content->users->{'0'}->user->{'0'};

echo '<pre>'; 
foreach($data as $d){

    $subdata = $d->team;

    foreach($subdata as $sd){
        echo 'name: ' .  $sd->name; //this line errors
    }
 }
  • 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-08T23:12:19+00:00Added an answer on June 8, 2026 at 11:12 pm

    You should go two levels deeper, under team there’s another array and only this array contains the array with name:

    [team] => Array
                    (
                        [0] => Array (
                           [0] => stdClass Object
                                (
                                    [team_key] => 273.l.73856.t.9
                                )
    
                           [1] => stdClass Object
                                (
                                    [team_id] => 9
                                )
    
                           [2] => stdClass Object
                           (
                                [name] => Team API
                           )
                           ...
                        )
                    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having a hard time working with arrays. Coming from AS2/AS3 and garbage collection
I am having a hard time using the $op variable when working with forms.
I'm currently trying to get into jQuery. And I'm having a hard time (-;
I'm new to JSON & am having a hard time trying to get my
I'm having a hard time trying to solve this. Here is my sample code:
Having a hard time parsing XML created from a web-form using POST. Here's the
I'm having a hard time getting SetSystemTime working in my C# code. SetSystemtime is
I'm working on a simple wall post and having a hard time trouble-shooting it.
I am working through the AHK docs but am having a hard time finding
I'm having hard time trying to figure out how to auto-save user data in

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.