Mega Code Archive

 
Categories / Php / File Directory
 

Better Get File Extension

<?php // Function that get file extension // Returns an empty string if file has no // extension // I try to use regular expression as much // as possible when working with strings // because this way you never have to deal // with string indexes. function ReallyGetFileExtension( &$filename ) { return ereg( ".([^\.]+)$", $filename, $r ) ? $r[1] : ""; } ?>