0

我有几个 json 编码的对象,我想将它们写入 json 文件。数据是从脸书收集的。例如,如果我这样做

$myfile="testson.json";
$fileout=fopen($myfile,'w') or die("Fatal: Can't write to JSON file");
$friends = idx($facebook->api('/me/friends?limit=5000'), 'data', array());//gather data from facebook
fwrite($fileout,json_encode($friends));

我得到这样的东西: [{"name":"xyz","id":"2342342"},{other entries alike}]

或者,对于同样的事情,喜欢:

 [{"category":"Musician\/band","name":"Jack Savoretti","id":"216730015024772","created_time":"2013-03-14T13:38:27+0000"},{other entries alike}]

现在我想做的是在某些类别下列出它们中的每一个。例如

        ["Likes":[{"category":"Musician\/band","name":"Jack Savoretti","id":"216730015024772","created_time":"2013-03-14T13:38:27+0000"},
{other entries alike}],  
    "friends":[{"name":"xyz","id":"2342342"},{other entries alike}]]

我怎样才能做到这一点?
我正在使用 php json_encode

4

0 回答 0