我已经发布了部分内容..但这是一个不同的问题
我有以下
foreach ($results['comments'] as $item) {
echo 'Date: '. $item['created_at'] .'<br/>';
echo 'Description : '. $item['html_body'] .'<br/>';
echo 'Attachments : '. $item['attacments->url'] .'<br/>';
echo 'Filename : '. $item['file_name'] .'<br/>';
echo "<br>";
}
所以基本上,我的日期和描述工作,但附件不会工作,b / c我不认为这是获取数组数组内的对象的正确方法?希望我正确解释。
comments数组将所有日期作为单个对象进行描述,因此它具有此尾随。
[public] => 1 [trusted] => 1 [attachments] => Array ( [0] => Array ( [url] => https://url/api/v2/attachments/IDHERE.json [id] => ID#[file_name] => name of file here
答案 0 :(得分:2)
看一下你的数组转储
[public] => 1
[trusted] => 1
[attachments] => Array (
[0] => Array (
[url] => https://url/api/v2/attachments/IDHERE.json
[id] => ID#
[file_name] => name of file here
获取如下值:
$Attachments = $item['attachments'];
$AttachmentsUrl = $Attachments[0]['url'];
$Attachmentsid = $Attachments[0]['id'];
$AttachmentsFileName = $Attachments[0]['file_name'];