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!
I have a string that contains a filename, ie. index.php. I need to get a way to remove the .php from the filename. Can anyone suggest a way to get the name without the extension. Also, the filename can be different, but it will always end with .php.
Thanks for your help
Sphen001
Last edited by Sphen001 on Tue Jul 12, 2005 9:23 pm, edited 1 time in total.
Give this a shot. It checks to see if it ends with .php and does a substring to parse the name. There's a bunch of ways to do this... but this is one option.
If you don't mind, could you explain how this regex works? I'm trying to learn how to do them myself, and I think real examples would be helpful. I've looked at several resources, and I'm starting to get the hang of it, but this would be really great.
I don't reccomend using that code, as a filename could contain more than just one full stop. basename() can also be used if you just want to delete a single defined extension.
Regular expression for deleting any extension from the filename: