How to get text: “Text example max” from:
<td valign="top" align="left">
<a href="/server?tree=xabaf"
class="normal"> Text example max </a>
</td>
using regular expression?
include('simple_html_dom.php');
$ch = curl_init('http://www.site.com?id=325235');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$sss = curl_exec($ch);
curl_close($ch);
preg_match_all("#class="normal"?</a>$#", $sss, $arr);
Solution using REGEX
PHP’s DOM
$text = "<a href='/server?tree=xabaf' class='normal'> Text example max </a>"; $dom = new DOMDocument; $dom->loadHTML($text); $links = $dom->getElementsByTagName('a'); foreach ($links as $link){ echo $link->textContent; }Use DOM and not regex.