communication
 databases
 directories
 file handling
 html and code
 image editing
 image listing
 sessions and co
 string handling
 information
 forms
 apple stuff
 image handling
 array handling
 lixlpixel
php - snippets
google search terms detected and highlighted.
remove highlighting | keep highlighting
make snippet in "file handling" - download "strip file extension" - open demo of "strip file extension"
 search
php - snippets

Valid CSS!

php webring logo
prev next
random list
join the Ring!

file handling - strip file extension was created/last modified on Mon 10 May 2004 6:11 AM

this php code will strip the extension from a filename.
to remove the extension just call the function with  the name of the file
   
<?php
  
  
function strip_ext($name)
{
     
$ext = strrchr($name, '.');
     if(
$ext !== false)
     {
         
$name = substr($name, 0, -strlen($ext));
     }
     return
$name;
}

$filename = 'file_name.txt';

echo
strip_ext($filename);
  
?>

learn more about some of the PHP functions used in this snippet: chr, echo, file, function, return, strlen, strrchr, substr

view the GNU general license - view the GNU library license - search on PHPsnippets - see your code like this

 a lixlpixel.com site

PHParadise.com - PHP-classes.org - your site on safari