I have a json response like following
{"name":['abc','def','ghi','jkl']}
How can i extract each of those names in php?
expected out put :
abc
def
ghi
jkl
I have a json response like following
{"name":['abc','def','ghi','jkl']}
How can i extract each of those names in php?
expected out put :
abc
def
ghi
jkl
Use json_decode
and
See this link
function.json-decode.php
$jsons=array('name'=>array("abc","def","ghi","jkl"));
foreach($jsons as $json ){
foreach($json as $val){
echo $val .'<br>';
}
}
Use like this
<?php
$var = '{"name":["abc","xyz"]}';// here will be your response
$arr = json_decode($var);
foreach($arr->name as $key=>$value)
echo $value."<br/>";
?>