This is html text in the website, i want to grab
1,000 Places To See Before You Die
-
Why not DOMDocument
and get title attribute?:
$string = '
-
1,000 Places To See Before You Die
2009
';
$dom = new DOMDocument;
$dom->loadHTML($string);
$xpath = new DOMXPath($dom);
$text = $xpath->query('//ul[@class="listings"]/li/a/@title')->item(0)->nodeValue;
echo $text;
or
$text = explode("\n", trim($xpath->query('//ul[@class="listings"]/li/a')->item(0)->nodeValue));
echo $text[0];
Codepad Example