PHP多维阵列至CSV
我一直在旋转车轮,试图在此多维数组中浏览值,以创建一个CSV文件。我的API调用返回以下内容(请参阅图像)。
我如何将这些值放在CSV文件中,显然,标头首先出现,然后是记录行?
即使是我正在使用测试的for for for for的帮助也很有价值,因为它没有返回,但没有错误:
$data = json_encode(array("data" => $report_data));
foreach ($data->header as $n => $header) {
$hdr = $header->values->data[0];
}
echo $hdr;
谢谢!
I've been spinning my wheels trying to fetch/loop through the values in this multidimensional array in order to create a csv file. My API call returns the following (see image).
How do I place these values in a csv file where, obviously, the header comes first and then the record lines?
Even help with this foreach I'm using for testing would be of value as it returns nothing, but no error:
$data = json_encode(array("data" => $report_data));
foreach ($data->header as $n => $header) {
$hdr = $header->values->data[0];
}
echo $hdr;
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
假设您的PHP阵列看起来像
这样
Assuming your PHP array looks like this
Then this should do the trick