<br>------------------------------ <div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>Message: 6<br>Date: Fri, 1 Feb 2008 11:46:42 -0500<br>
From: "Kevin Squire" <<a href="mailto:gentgeen@wikiak.org">gentgeen@wikiak.org</a>><br>Subject: [wplug] PHP script question<br>To: <a href="mailto:wplug@wplug.org">wplug@wplug.org</a><br>Message-ID:<br> <<a href="mailto:386ebf050802010846u78385d82o224fb4756c4e09ab@mail.gmail.com">386ebf050802010846u78385d82o224fb4756c4e09ab@mail.gmail.com</a>><br>
Content-Type: text/plain; charset="iso-8859-1"<br><br>First - Thank you, those of you that replied to my last PHP question - I<br>have not researched what you mentioned yet, but will and will reply back on<br>that thread later.<br>
<br>I am thinking of using the Dynamic Site Map Generator found here -<br><a href="http://apptools.com/phptools/dynamicsitemap.php" target="_blank">http://apptools.com/phptools/dynamicsitemap.php</a> I searched the site for<br>
some form of "contact me" as well as searched the source code, but had no<br>luck - so I was hoping you all could help me out again.<br><br>There is a function that searches the webpages for the TITLE tag, then<br>
reports back using the contents of that tag. The one problem I have is that<br>all our pages have a title format of:<br> PAGE TITLE | COMPANY NAME<br><br>So my sitemap then gets filled with " | COMPANY NAME" after every single<br>
page title - very cluttered and difficult to browse. It could work, but I<br>would really like to clean it up some. I would like to add to the PHP<br>function the equivalent of the command:<br> cut -f1 -d"|"<br>
But I have no idea how to do so.<br><br>Here is the function<br><br>function getTitle($file){<br> global $htmltypes;<br> $title="";<br> $p=pathinfo($file);<br> if(!in_array(strtolower($p['extension']),$htmltypes)){<br>
$f=file_get_contents($file);<br> if(preg_match("'<title>(.+)</title>'i", $f, $matches)){<br> $title=$matches[1];<br> }<br> }<br> $title=$title?$title:basename($file);<br>
return htmlentities(trim(strip_tags($title)));<br>}<br><br><br>--<br><a href="http://gentgeen.homelinux.org" target="_blank">http://gentgeen.homelinux.org</a></blockquote><div><br><br>I think it will so long as there's only one '|' in $title, this will work. Then you should find the title you want in $extracted_title<br>
<br><br> if( !is_null( $title )){<br> $co_name = trim( substr(strrchr($title, "|"), 1));<br> $extracted_title = trim( substr($title, 0, strripos($title, "|")));<br> echo "<br>Page title: " . $extracted_title . "\t\tCompany Name: " . $co_name;<br>
}<br><br> <br>--Chad<br></div></div><br>