Blog

Blog Post

Thanks for visiting! If you're new here, you may want to subscribe to our RSS feed or Subscribe to Email update. You will find all kinds of things about technology here!

PHP: Remove File Extension

While writing a script to list the file in a specified folder on the server I wanted to remove file extension from the file name before I link it. Here is the php code that will remove the file extension.

< ? php
if(!function_exists("RemoveExtension"))
{
function RemoveExtension($strName)
{
$ext = strrchr($strName, '.');
if($ext !== false) {
$strName = substr($strName, 0, -strlen($ext));
}
return $strName;
}
}
? >

If you enjoyed this post, make sure you subscribe to my RSS feed!

Tags: , , , , , ,

Comments are closed.

Feedback Form