Blog

Recent Blog Posts

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;
}
}
? >