In my search engine result outputs, how can I make it to show page title?
Feb 27th, 2008 00:03
dman, Nick Brandt, Nick Tucker, http://www.ttnr.org
I assume that at some stage you open and index/extract data from a
page, to get the title from that page you can use the code below:
// Get the webpage into a string
$html = join ("", file ("http://www.altavista.com/"));
// Using eregi
eregi("<title>(.*)</title>", $html, $tag_contents);
// Using preg_match (faster than eregi)
// The i in the end means that it is a case insensitive match
preg_match("/<title>(.*)<\/title>/i", $html, $tag_contents);
// $title now contains title, 'AltaVista - The Search Company'
$title = $tag_contents;