| AND OR | string words | *

file handling

|

strip file extension

| see demonstration of strip file extension


this php code will strip the extension from a filename.
to remove the extension just call the function with the name of the file


function strip_ext( ) [ line 2 ]



full source of strip file extension [ line 1 - 16 ] | download strip file extension

1    <?php
2   function strip_ext($name)
3   {
4       $ext strrchr($name'.');
5       if($ext !== false)
6       {
7           $name substr($name0, -strlen($ext));
8       }
9       return $name;
10   }
11   // demonstration
12   $filename 'file_name.txt';
13   echo strip_ext($filename)."n";
14   // to get the file extension, do
15   echo end(explode('.',$filename))."n";
16   ?>



26 hits by 16 users in the last 30 minutes.