Solved

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

Posted on 2015-01-20
2
91 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 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

These days socially coordinated efforts have turned into a critical requirement for enterprises.
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

821 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