PHP MySQL Tutorial
Learn PHP and MySQL

Remove a File Extention Using PHP

100% of people found this useful
Remove a File Extention Using PHP

To strip the file extension from a file name you can use the combination of strrpos() and substr() function like this :

$name = substr($fileName, 0, strrpos($fileName, '.'));

For example, if $fileName is my-pretty-flowers.jpg then strrpos($fileName, '.') will return the last location a dot character in $fileName which is 17. So substr($fileName, 0, strrpos($fileName, '.')) equals to substr($fileName, 0, 17) which returns 'my-pretty-flowers'

Powered by Community Server (Non-Commercial Edition), by Telligent Systems