Solved

How to use/display arrayed results from json decode?  Example needed

Posted on 2015-01-20
2
84 Views
Last Modified: 2015-01-21
Ok, I've got json data and decoded it with json_decode:

      $data = json_decode($json_info,true);

when I do this:

      var_dump($data);

I get results like this:

   http://shoutkey.com/expulsion

Now that I've got that array.... I'm not sure how to use it.

Can you give me an example of code that will display the first six results for the ChannelName, DisplayTime and ProgramTitle, after they are parsed, so I have:

ChannelName value 1, DisplayTime value 1, ProgramTitle value 1
ChannelName value 2, DisplayTime value 2, ProgramTitle value 2
ChannelName value 3, DisplayTime value 3, ProgramTitle value 3
ChannelName value 4, DisplayTime value 4, ProgramTitle value 4
ChannelName value 5, DisplayTime value 5, ProgramTitle value 5

Big ask I know, I would really appreciate the help!
0
Comment
Question by:St_Aug_Beach_Bum
2 Comments
 
LVL 33

Accepted Solution

by:
Slick812 earned 500 total points
ID: 40562350
$tvShows = json_decode($json_info,true);

for ($i = 0; $i < 5) {
    echo 'ChannelName is '. $tvShows[$i]["ChannelName"]. 
    ', DisplayTime is ' .$tvShows[$i]["DisplayTime"]. 
    ', ProgramTitle is ' .$tvShows[$i]["ProgramTitle"] . '<br />';
    }

Open in new window

I think this should work, although I did not test it.
  Ask questions if you need more information.
0
 

Author Closing Comment

by:St_Aug_Beach_Bum
ID: 40562690
Got it!

I had to change the 'for' to this:

for ($i = 0; $i <= 5; $i++) {   //based on example at php.net

but you got me going in the right direction here - thank you very much!

Chris
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now