Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2015-01-20
2
Medium Priority
?
100 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 34

Accepted Solution

by:
Slick812 earned 2000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
It’s a season to be thankful, and we’re thankful for users like you who engage on site, solve technology problems, and network with others in the industry. What tech are we most thankful for? Keep reading.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

885 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