Get particular matching values from json array using php code -
this response code:
'[{"id":"153","title":"xyz","description":"abc"}, {"id":"154","title":"xyy","description":"abb"}]'
in code need values id=154 , need particular array values using php code?
if have variable $a=154; particular id , title , description values only. if have variable $a=153; particular id , title , description values only.
$jsonstr = '[ {"id":"153","title":"xyz","description":"abc"}, {"id":"154","title":"xyy","description":"abb"} ]'; $arrjson = json_decode($jsonstr); $keyval = 154; foreach($arrjson $key => $val){ if($val->id == $keyval){ echo $val->id;//id echo $val->title;//title echo $val->description;//descrption } }
Comments
Post a Comment