<br>------------------------------&nbsp;<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: &quot;Kevin Squire&quot; &lt;<a href="mailto:gentgeen@wikiak.org">gentgeen@wikiak.org</a>&gt;<br>Subject: [wplug] PHP script question<br>To: <a href="mailto:wplug@wplug.org">wplug@wplug.org</a><br>Message-ID:<br> &nbsp; &nbsp; &nbsp; &nbsp;&lt;<a href="mailto:386ebf050802010846u78385d82o224fb4756c4e09ab@mail.gmail.com">386ebf050802010846u78385d82o224fb4756c4e09ab@mail.gmail.com</a>&gt;<br>
Content-Type: text/plain; charset=&quot;iso-8859-1&quot;<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> &nbsp;I searched the site for<br>
some form of &quot;contact me&quot; 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. &nbsp;The one problem I have is that<br>all our pages have a title format of:<br> &nbsp; &nbsp; &nbsp; PAGE TITLE | COMPANY NAME<br><br>So my sitemap then gets filled with &quot; | COMPANY NAME&quot; after every single<br>
page title - very cluttered and difficult to browse. &nbsp;It could work, but I<br>would really like to clean it up some. &nbsp;I would like to add to the PHP<br>function the equivalent of the command:<br> &nbsp; &nbsp; cut -f1 -d&quot;|&quot;<br>
But I have no idea how to do so.<br><br>Here is the function<br><br>function getTitle($file){<br> &nbsp; &nbsp;global $htmltypes;<br> &nbsp; &nbsp;$title=&quot;&quot;;<br> &nbsp; &nbsp;$p=pathinfo($file);<br> &nbsp; &nbsp;if(!in_array(strtolower($p[&#39;extension&#39;]),$htmltypes)){<br>
 &nbsp; &nbsp; &nbsp; &nbsp;$f=file_get_contents($file);<br> &nbsp; &nbsp; &nbsp; &nbsp;if(preg_match(&quot;&#39;&lt;title&gt;(.+)&lt;/title&gt;&#39;i&quot;, $f, $matches)){<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$title=$matches[1];<br> &nbsp; &nbsp; &nbsp; &nbsp;}<br> &nbsp; &nbsp;}<br> &nbsp; &nbsp;$title=$title?$title:basename($file);<br>
 &nbsp; &nbsp;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&#39;s only one &#39;|&#39;&nbsp; in $title, this will work.&nbsp; Then you should find the title you want in $extracted_title<br>
<br><br>&nbsp;&nbsp;&nbsp; if( !is_null( $title )){<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;$co_name = trim( substr(strrchr($title, &quot;|&quot;), 1));<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;$extracted_title = trim( substr($title, 0, strripos($title, &quot;|&quot;)));<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;echo &quot;&lt;br&gt;Page title:&nbsp; &quot; . $extracted_title . &quot;\t\tCompany Name: &quot; . $co_name;<br>
&nbsp;&nbsp;&nbsp; }<br><br>&nbsp;<br>--Chad<br></div></div><br>