This is html text in the website, i want to grab
1,000 Places To See Before You Die
-
There are 2 ways that I could think of to solve this. One, is that you grab the title attribute from the anchor tag. Of course, not everyone set up a title attribute for the anchor tag and the value of the attribute could be different if they want to fill it that way. The other solution is that, you get the innertext
attribute and then replace every child of the anchor tag with an empty value.
So, either do this
$e->title;
or this
$text = $e->innertext;
foreach ($e->children() as $child)
{
$text = str_replace($child, '', $text);
}
Though, it might be a good idea to use DOMDocument instead for this.