PHP JSON value if exist then -


i have small json file , want check if "fullday":"no" in object. if true needs output no.

how can php?

 {     "calendar": {         "title": "agenda punten",         "agenda": [             {                 "id":1,                 "datum": "2015-07-13",                 "title": "titel agendapunt #1",                 "beschrijving": "dit een beschrijving",                 "fullday": "no"             },             {                 "id":2,                 "datum": "2015-07-14",                               "title": "titel agendapunt #2",                 "beschrijving": "dit een beschrijving",                  "fullday": "yes"                                                 }         ]     } } 

thanks!

try this..

<?php $json='{     "calendar": {                     "title": "agenda punten",                     "agenda": [              {       "id":1,                     "datum": "2015-07-13",                     "title": "titel agendapunt #1",                     "beschrijving": "dit een beschrijving",                     "fullday": "no"             },             {       "id":2,                     "datum": "2015-07-14",                                   "title": "titel agendapunt #2",                     "beschrijving": "dit een beschrijving",                      "fullday": "yes"                                                 }         ]     } }';  $data=json_decode($json,true); $getdata=$data['calendar']['agenda'];  foreach($getdata $value) {     if($value['fullday']=='no')     {         echo 'title:'.$value['title'].'</br>';     } } ?> 

answer-> title:titel agendapunt #1


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -