我有一个名为test.txt以下内容的文本文件:
{"FirstName":"John","Title":"","Surname":"Smith"}
{"FirstName":"Daniel","Title":"","Surname":"Smith"}
我想在PHP脚本中循环浏览此JSON,因此最终输出是:
John Smith
Daniel Smith
我当前的PHP代码是:
$fn = fopen("./test.txt","r");
while(! feof($fn)) {
$line = fgets($fn);
// grab data from JSON
}
fclose($fn);
如何获取每个元素并将其输出到页面中?
陪伴而非守候