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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T23:39:15+00:00 2026-05-13T23:39:15+00:00

Array ( [status] => success [stories] => Array ( [0] => Array ( [name]

  • 0
Array ( [status] => success 
        [stories] => Array ( 
              [0] => Array ( [name] => John Doe 
                             [age] => 23)
              [1] => Array ( [name] => John Doe_1
                             [age] => 23)
              [2] => Array ( [name] => John Doe_2
                             [age] => 23)
       )
)    

When I try

foreach($stories as $story){ }

It returns an error.

Update: I am trying to pull out the most recent stories from Tweetmeme. Since the json output was long, I shortened it. 🙂

The PHP Code:

$json=file_get_contents($url);
        $data=json_decode($json,true);
        print_r($data);

        foreach($stories as $story){
                $title = mysql_real_escape_string($story['title']);
                $url_temp = mysql_real_escape_string($story['url']);
                $tweets = intval($story['url_count']);


JSON Output:

Array ( [status] => success 
         [stories] => Array ( [0] => Array ( [title] => Steve Jobs has a Flash enabled iPad! [photo] [url] => http://thenextweb.com/shareables/2010/03/08/flash-ipad/ [media_type] => news [created_at] => 2010-03-08 09:11:40 [url_count] => 151 [tm_link] => http://tweetmeme.com/story/688449947 [comment_count] => 0 [excerpt] => Steve Jobs has a Flash enabled iPad! http://tnw.to/15mht [photo] [alias] => http://ow.ly/1pVNX0 [retweet] => RT @tweetmeme Steve Jobs has a Flash enabled iPad! [photo] http://ow.ly/1pVNX0 ) [1] => Array ( [title] => Scientists reaffirm theory that giant asteroid killed dinosaurs - CNN.com [url] => http://www.cnn.com/2010/TECH/science/03/08/dinosaurs.asteroid/ [media_type] => news [created_at] => 2010-03-08 08:12:37 [url_count] => 222 [tm_link] => http://tweetmeme.com/story/688253916 [comment_count] => 0 [excerpt] => (CNN) -- A team of scientists has agreed that a giant asteroid killed off dinosaurs and a majority of other species on Earth more than 65 million years ago. [thumbnail] => http://tweetmeme.s3.amazonaws.com/thumbs/688253916.jpg [alias] => http://ow.ly/1pVG7L [retweet] => RT @tweetmeme Scientists reaffirm theory that giant asteroid killed dinosaurs - CNN.com http://ow.ly/1pVG7L ) [2] => Array ( [title] => The New York Times is hiring 12 techies and a social media whiz [url] => http://venturebeat.com/2010/03/08/nyt-nytimes-hiring/ [media_type] => news [created_at] => 2010-03-08 10:30:57 [url_count] => 199 [tm_link] => http://tweetmeme.com/story/688719545 [comment_count] => 1 [excerpt] => While pundits climb over each other to predict the death of The New York Times Company, the NYT is looking to hire at least a dozen full-time software engineers and Web designers, plus one social media marketing manager. One opening carries the sexy title of Creative Technologist.The jobs, located in New York City, will focus on expanding content distribution and advertising opportunities in… [thumbnail] => http://tweetmeme.s3.amazonaws.com/thumbs/688719545.jpg [alias] => http://bit.ly/bFqAm7 [retweet] => RT @tweetmeme The New York Times is hiring 12 techies and a social media whiz http://bit.ly/bFqAm7 ) 
  • 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-13T23:39:16+00:00Added an answer on May 13, 2026 at 11:39 pm

    You simply forgot to initialize the variable $data. Please include this line before the for-loop:

    $stories = $data['stories'];
    

    Keep in mind that json_decode itself does not create local variables!

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

Sidebar

Related Questions

I have these code in my views.py: array = [] p = Person.objects.filter(client=1,status='Complete').values('name', 'age',
I'm sending the following from PHP to JSON print json_encode(array('success' => TRUE, 'status' =>
Here is my JSON which I need to parse: {opcode:groupdetails, status:success, data:[{Group ID:5,Group Name:data
Example: var arr_1:Array = new Array(); arr_1.push({sdate:2010-02-02,status:New}); arr_1.push({sdate:2010-02-03,status:New}); arr_1.push({sdate:2010-02-04,status:New}); arr_1.push({sdate:2010-02-05,status:New}); How can i change
My query: mysql::getInstance()->update('requests', array('response' => mysql_real_escape_string($_POST['status'])), array('secret' => $_POST['secret'])); ?> If i wand to
I'm trying to create an array (States) of arrays (Cities). Whenever I try to
I am receiving an error in my error console which states: arguments array passed
I have array of hashes: @array = [{:id => 1, :status=>R}, {:id => 1,
My PHP side sends reponse to ajax like that $data = array( 'status' =>
What is a decent way to handle PDO error when using try catch block?

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.