私はPHPの初心者であり、JSONコンテンツを印刷するのに問題があります
これは私のコードです
//Read text file
$json_data = file_get_contents('data/data.txt');
//Decode it
$obj=json_decode($json_data, true);
//Print array content
print_r($obj);
//Loop the array to write content
foreach( $obj as $Item ){
// add comment to html list
echo $Item;
}
私のJSONファイル
[{"name":"ken"}, {"name":"barbie"}]
私の出力
(
[0] => Array ( [name] => ken )
[1] => Array ( [name] => barbie )
)
ArrayArray
「ケン」と「バービー」だけを印刷するにはどうすればよいですか?
ありがとう!