getting a variable from a file

From: Date: Fri, 23 Mar 2007 10:47:31 +0000
Subject: getting a variable from a file
Groups: php.general 
Request: Send a blank email to php-general+get-251160@lists.php.net to get a copy of this message
I am using a script to generate a sitemap. It displays the page names (mypage.php) but I want it to display the titles. The page heads and <title> are generated dynamically so the line below does not work if(preg_match("'<title>(.+)</title>'i", $f, $matches)){ However all the paged titles are stored in a variable $pageTitle. On every page like this $pageTitle="Who We Are"; how can I retrieve this variable? I tried echo $pageTitle and $_GET['pageTitle'] function getTitle($file){ global $htmltypes; $title=""; $p=pathinfo($file); if(!in_array(strtolower($p['extension']),$htmltypes)){ $f=file_get_contents($file); if(preg_match("'<title>(.+)</title>'i", $f, $matches)){ $title=$matches[1]; } } $title=$title?$title:basename($file); return htmlentities(trim(strip_tags($title))); } ?>

« previous php.general (#251160) next »