This little snippet will show you how to get string contain the title of an HTML file that located between
First, create a string containing the HTML file:
< ?php
$a = fopen("html_file.html","r");
$string = fread($a,1024);
?>
Why we just read 1024 bytes? Because the <title> tag mostly located at the top part, which is covered by first 1024 byte. Well, actually it’s up to you how many byte you will read. :p
Then simply filter the string using eregi() function. We use eregi() so it will filter both TITLE and title tag (case insensitive).
< ?php
// get text inbetween
if (eregi("
$outdata = $out[1];
}
// display it
echo $outdata.
?>
Happy coding! ^_*
Leave a Reply