0

I'm currently getting dates from a web page by using the following

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

var_dump($articles);

Which will output the following

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 } } 

I would ideally like to get the results to lay out as listed like so

  • Important Dates
  • Expires On October 28, 2013
  • Registered On October 29, 2012
  • Updated On October 29, 2012

But I am lost with getting the content to echo correctly as echo $articles just produces Array and I have never had such an Array before like this one

1
  • I was very happy to see that you are using a parser to process HTML (rather than a regex, which many people seem to think is acceptable)... but then I find you're having trouble with trivial array access and simple string manipulation... It seems a bit of an oxymoron ;) Commented Nov 2, 2013 at 13:09

2 Answers 2

2

try:

echo $articles[0]["dates"];
Sign up to request clarification or add additional context in comments.

Comments

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

you cannot use echo to output array

foreach($articles as $strarticle)
{
 echo $strarticle;
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.