0

我目前正在使用以下方法从网页获取日期

foreach($returned_content->find('div.box-inset') as $article) {
    $item['dates'] = $article->find('div.important-dates', 0)->plaintext;
    $articles[] = $item;
}

var_dump($articles);

这将输出以下内容

array(2) { [0]=> array(1) { ["dates"]=> string(235) " Important Dates Expires On October 28, 2013 Registered On October 29, 2012 Updated On October 29, 2012 " } [1]=> array(1) { ["dates"]=> NULL } } 

理想情况下,我希望将结果按如下所示列出

  • 重要的日子
  • 2013 年 10 月 28 日到期
  • 2012 年 10 月 29 日注册
  • 更新于 2012 年 10 月 29 日

但是我迷失了让内容像echo $articles刚刚产生的那样正确回显,Array而且我以前从来没有像这样的数组

4

2 回答 2

2

尝试:

echo $articles[0]["dates"];
于 2013-11-02T13:09:19.210 回答
1
foreach($returned_content->find('div.box-inset') as $article) {
    $item['dates'] = $article->find('div.important-dates', 0)->plaintext;
    $articles[] = $item['dates'];
}

你不能使用 echo 来输出数组

foreach($articles as $strarticle)
{
 echo $strarticle;
}
于 2013-11-02T13:10:13.387 回答