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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:47:33+00:00 2026-06-13T12:47:33+00:00

JSON FEED: { Group: [ { name: HolderOne, operators: [ { username: ken, status:

  • 0

JSON FEED:

    {
        "Group": [
          {
             "name": "HolderOne",
            "operators": [
            {
                "username": "ken",
                "status": 3
            },
     .....etc.....

CODE:

 <?php 
 $json = file_get_content('path to feed');
 $data=json_decode($json); 

 echo $data->cGroup[0]->operators[0]->username; //WORKS!

 if (is_array($data->Group->operators))
  { foreach($data->Group->operators as $operator) 
     {if($operator->username == "ken") {echo $operator->status;}} 
  } else { echo 'NOT AN ARRAY'; } //DOESNT WORK - DISPLAYS NOT AN ARRAY
 ?>

I am trying to say if the username is Ken (or whatever I specify when I code more) display the correspoding status.

So…

  echo $data->Group[0]->operators[0]->username; //WORKS!

but…

    foreach($data->Group->operators as $operator) {if($operator->username == "ken") {echo $operator->status;}} 

…doesn’t – probably something obvious, but can anyone see my problem?

Cheers
Andy

  • 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-13T12:47:34+00:00Added an answer on June 13, 2026 at 12:47 pm

    It would have to be $data->Group[0]->operators, or loop through the Groups and have another loop inside…

    foreach($data->Group as $group){
        foreach($group->operators as $operator){
            if($operator->username == "ken") {echo $operator->status;}
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

{ Group: [ { name: HolderOne, operators: [ { username: ken, status: 3 },
I m parsing a json feed containing three tags they are Name,Status,Image and storing
I have a JSON feed data with lots of user relation in it such
I'm trying to scrape data from an external JSON feed and store it in
I would like to interpret data from JSON feed using jQuery getJSON. $(function() {
I'm creating a JSON feed with PHP using echo json_encode($my_array) . The resulting string
When i get a json feed from a Cyrillic site, the data is in
I am downloading data from twitter using JSON feed by using SBJSON Framework example.
I have the following code which loads a JSON feed and creates all the
I have a JSON feed that I'm parsing. Here's the following code samples: JSON

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.