Código PHP:
<?php
$url = 'datos.html';
// Obtengo el contenido de la web
$text = file_get_contents($url);
//function to get a substring between between two other substrings
function substring_between($haystack,$start,$end) {
if (strpos($haystack,$start) === false || strpos($haystack,$end) === false) {
return false;
} else {
$start_position = strpos($haystack,$start)+strlen($start);
$end_position = strpos($haystack,$end);
return substr($haystack,$start_position,$end_position-$start_position);
}
}
$text = htmlspecialchars($text);
$title = substring_between($text,'<title>','</title>');
echo $title;
?>
Por ahora tengo esto y me imprime lo que esta en <title></title> pero al querer lo que esta en <div align="center" class="ensbustermenu">-0.88</div> no me imprime nada.
Que estoy haciendo mal?