How to display page name without extension

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
spamyboy
Forum Contributor
Posts: 266
Joined: Sun Nov 06, 2005 11:29 am
Location: Lithuania, vilnius

How to display page name without extension

Post by spamyboy »

Twigletmac | Please use meaningful titles for your threads (I have adjusted this one to aid other people searching for information)

How to display in page title file name (for e.g. if http://www.gooogle.com then topic would be index.php) but without ".php"?
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

Assuming you have a string $title that contains "index.php". All you have to do is make a string without the last 4 characters: http://www.php.net/substr is a good place to start...
User avatar
spamyboy
Forum Contributor
Posts: 266
Joined: Sun Nov 06, 2005 11:29 am
Location: Lithuania, vilnius

Post by spamyboy »

Thanks :)
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

You can also use basename()

Mac
Post Reply