samedi 22 juillet 2017

How to skip json object if it has a empty value?

I'm stuck on this since many days... I'm using this code to parse a json EPG guide stored on a server:

<?php
$channel = '899';
$current_unix = time();
$json = json_decode(file_get_contents('http://ift.tt/2ulcbhk'.date('y_m_d').'/ch_'.$channel.'.js', true));
echo '<ul>';
foreach ($json->plan as $prog) {
echo "<li>" . $prog->title . "</li>";
echo '</ul>';  
}
?> 

I would like to skip this part of the json from showing because it has empty fields

"banned":true,
"plan":[
{"id":"-1",
"pid":"0",
"starttime":"00:00",
"dur":"65",
"title":"",
"normalizedtitle": "",
"desc":"",
"genre":"",
"subgenre":"",
"prima":false 
},

How can I do that?

Aucun commentaire:

Enregistrer un commentaire