[wplug] PHP script question

Kevin Squire gentgeen at wikiak.org
Fri Feb 1 11:46:42 EST 2008


First - Thank you, those of you that replied to my last PHP question - I
have not researched what you mentioned yet, but will and will reply back on
that thread later.

I am thinking of using the Dynamic Site Map Generator found here -
http://apptools.com/phptools/dynamicsitemap.php  I searched the site for
some form of "contact me" as well as searched the source code, but had no
luck - so I was hoping you all could help me out again.

There is a function that searches the webpages for the TITLE tag, then
reports back using the contents of that tag.  The one problem I have is that
all our pages have a title format of:
       PAGE TITLE | COMPANY NAME

So my sitemap then gets filled with " | COMPANY NAME" after every single
page title - very cluttered and difficult to browse.  It could work, but I
would really like to clean it up some.  I would like to add to the PHP
function the equivalent of the command:
     cut -f1 -d"|"
But I have no idea how to do so.

Here is the function

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)));
}


-- 
http://gentgeen.homelinux.org

#############################################################
Associate yourself with men of good quality if you esteem
your own reputation; for 'tis better to be alone then in bad
company.        - George Washington, Rules of Civility
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.wplug.org/pipermail/wplug/attachments/20080201/856f695a/attachment.html


More information about the wplug mailing list