getting a variable from a file
- From: ross@xxxxxxxxxxxxx ("Ross")
- Date: Fri, 23 Mar 2007 10:47:31 -0000
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)));
}
?>
.
- Follow-Ups:
- Re: [PHP] getting a variable from a file
- From: "Richard Lynch"
- Re: getting a variable from a file
- From: "Ross"
- Re: [PHP] getting a variable from a file
- Prev by Date: Re: [PHP] Question before upgrading to 5
- Next by Date: Keep-Alive problem
- Previous by thread: How to get class constants with there value?
- Next by thread: Re: getting a variable from a file
- Index(es):
Relevant Pages
|