我有一个json响应,如下面的
{"name":['abc','def','ghi','jkl']}
如何在php中提取每个名称?
expected out put :
abc
def
ghi
jkl
答案 0 :(得分:1)
使用json_decode
和
$jsons=array('name'=>array("abc","def","ghi","jkl"));
foreach($jsons as $json ){
foreach($json as $val){
echo $val .'<br>';
}
}
答案 1 :(得分:0)
像这样使用
<?php
$var = '{"name":["abc","xyz"]}';// here will be your response
$arr = json_decode($var);
foreach($arr->name as $key=>$value)
echo $value."<br/>";
?>