【发布时间】:2015-12-17 18:59:23
【问题描述】:
我有这个提供者数组
[
{
"reference":"01042",
"images": [
"http:\/\/static1.provider.com\/34\/01042.jpg"
]
},
{
"reference":"01057",
"images":[
"http:\/\/static1.provider.com\/57\/01057.jpg",
"http:\/\/static3.provider.com\/58\/01057.jpg",
"http:\/\/static2.provider.com\/59\/01057.jpg"]
},
...
]
我用下面的代码导出
$json_file2 = file_get_contents('http://direct.provider.com/public/ref_urlimage_20.json', false);
$decoded = json_decode($json_file2);
$fp = fopen('imagenes.csv', 'w');
foreach($decoded as $comment) {
fputcsv($fp, $comment);
}
fclose($fp);
但它显示了以下结果
01104,Array
01119,Array
40460,Array
00311,Array
00312,Array
00307,Array
当你需要导出到这种格式时
01104,http://static3.provider.com/155/01119.jpg
01119,http://static3.provider.com/155/04519.jpg,http://static3.provider.com/155/01148.jpg,http://static3.provider.com/155/0859.jpg
40460,http://static3.provider.com/155/01119.jpg,http://static3.provider.com/155/01118.jpg
00351,http://static3.provider.com/175/07219.jpg
...
我哪里做错了? 谢谢
【问题讨论】: