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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:56:00+00:00 2026-06-03T06:56:00+00:00

I am retrieving data via JSON and PHP from a URL. I am having

  • 0

I am retrieving data via JSON and PHP from a URL.
I am having difficulty breaking the object apart and displaying the data. The PHP code seems to be working until I get to the for loops.

$jsonurl = 'http://myweb/api.php';
$json = file_get_contents($jsonurl);
$json_output = json_decode($json);
foreach ($json_output->Monitoring AS $monitoring) {
    foreach ($monitoring->Status AS $Status){
        echo $Status->Emailed;
        echo $Status->Status;
    }

Here is my data structure:

 object(stdClass)#12 (1) 
      { ["Monitoring"]=> array(10) { [0]=> object(stdClass)#13 (14) 
            { 
            ["Status"]=> string(30) "HTTP/1.1 302 Moved Temporarily"
            ["Emailed"]=> string(1) "0" } 
            [1]=> object(stdClass)#14 (14) { 
            ["Status"]=> string(30) "HTTP/1.1 302 Moved Temporarily" 
            ["Emailed"]=> string(1) "0" } 
            [2]=> object(stdClass)#15 (14) { 
            ["Status"]=> string(30) "HTTP/1.1 302 Moved Temporarily" 
            ["Emailed"]=> string(1) "0" } 
            [3]=> object(stdClass)#16 (14) { 
            ["Status"]=> string(30) "HTTP/1.1 302 Moved Temporarily"               
            ["Emailed"]=> string(1) "0" }
            } } 
  • 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-03T06:56:01+00:00Added an answer on June 3, 2026 at 6:56 am

    According to the data structure you put, you only need one foreach loop like:

    $jsonurl = 'http://myweb/api.php';
    $json = file_get_contents($jsonurl);
    $json_output = json_decode($json);
    foreach ($json_output->Monitoring AS $Status) {
        echo $Status->Emailed;
        echo $Status->Status;
    }
    

    in the first foreach loop, the value ($monitoring in your code, $Status in mine as I just renamed it) is not another array that you need to loop over. It would contain a std object with Emailed and Status as keys.

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

Sidebar

Related Questions

I'm writing an API for retrieving data from a JDBC-connected Java Servlet via JSON.
I'm having trouble retrieving data from the google api. When I run the code,
In the following code for retrieving data via a SQL query from the db,
For some reason I'm having a problem retrieving data from my database. It leaves
I have developed a VB.Net code for retrieving data from excel file .I load
I have code in C++ for saving and retrieving data from an XML file.
In my java code,I am retrieving some multibyte data from database and making some
I'm having trouble retrieving data from my database using Spring Jdbc. Here's my issue:
I'm retrieving data from a JSON feed using jQuery and as part of the
I am retrieving data from an Oracle database and binding the same to a

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.