If you want to get all inner texts of <span>
tags having lang-fr
in their class
attribute value, you can use the following DOMDocument/DOMXPath based solution:
$contents = file_get_contents("http://quizlet.com/9117/envol-7-unite-1-presentation-flash-cards/");
$dom = new DOMDocument;
@$dom->loadHTML($contents, LIBXML_HTML_NOIMPLIED|LIBXML_HTML_NODEFDTD);
$xp = new DOMXPath($dom);
$spans = $xp->query('//span[contains(@class,"lang-fr")]');
$arr = array();
foreach ($spans as $span) {
array_push($arr, $span->nodeValue);
}
print_r($arr);
See IDEONE demo
The xpath is '//span[contains(@class,"lang-fr")]'
here. You can make it stricter to only get all span tags with class attribute value equal to "TermText qWord lang-fr": '//span[@class="lang-fr"]'
.
This solution relieves you from the problem of matching this or that type of delimiting attribute values in HTML. And many other issues related to regex HTML parsing.