Solved

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

Posted on 2015-01-20
2
94 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
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 dynamically set the form action using jQuery.

739 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