How to replace an ending?

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
Darkside
Forum Commoner
Posts: 43
Joined: Wed Oct 30, 2002 4:18 pm

How to replace an ending?

Post by Darkside »

How could I drop the ending of a file name and then add differnt ends later in the code?
User avatar
lazy_yogi
Forum Contributor
Posts: 243
Joined: Fri Jan 24, 2003 3:27 am

Post by lazy_yogi »

$filename = preg_replace('/\.\w+$/','',$filename);
then to add it .txt do
$filename .= ".txt";
and similar to add whatever else
Darkside
Forum Commoner
Posts: 43
Joined: Wed Oct 30, 2002 4:18 pm

Post by Darkside »

thanks very much :P your like the only dood on this late
User avatar
lazy_yogi
Forum Contributor
Posts: 243
Joined: Fri Jan 24, 2003 3:27 am

Post by lazy_yogi »

It's not late ..... it's not even 7 pm here ....
Post Reply