This used to work fine to get me a text from a certain web page that exists in a div tag when a user type the id below:
function get_text($id) {
$result = file_get_contents('www.site.net/.$id.'');
$regex = '/<div class="x">([^<]*)<\/div>/';
if (preg_match($regex, $result, $matches) && !empty($matches[1])) {
return $matches[1];
} else {
return 'N/A';
}
}
Now the text is more difficult to get, because it's situated here:
<div class="X2">
<h2 style="font-family: 'Pacifico', cursive;">TEXT</h2>
</div>
I tried both div and h2 but it returns me nothing, please help ! thank you.