Reputation: 129
I have a list of values that I'm grabbing from a website, these are a few lines that I grabbed.
[{"durationString":"1 hour",
"programStatus":null,
"channelId":309,
"episodeNo":"0",
"title":"Nostradamus Effect",
"altSynopsis":null,
"startTimeMilis":1296543600000,
"id":1006843665,
"endTime":"Tue Feb 01 16:00:00 SGT 2011"
I'd like to separate and print only the ones I'm interested in, such as only title and channelID. How should I go about doing it?
Also there are multiple values of titles and endTime, I'd like to display all of them out
Solved it by using the code
foreach($values as $val){
echo $val["displayStartTime"];
echo " ";
echo $val["channelNumber"];
echo " ";
echo $val["channelName"];
echo ", ";
echo $val["title"];
echo "<br>";
Upvotes: 0
Views: 60
Reputation: 522500
Looks like you're dealing with JSON, so use json_decode
:
$values = json_decode($text, true);
echo $values[0]['channelId'];
Upvotes: 4