note 81386 deleted from function.filetype by philip

From: Date: Sun, 15 Jun 2008 03:15:43 +0000
Subject: note 81386 deleted from function.filetype by philip
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-140450@lists.php.net to get a copy of this message
Note Submitter: rich dot fleming at NOSPAM dot gmail dot com ---- In response to zachary.s.scott[at]gmail[dot]com. A simplified method would be to pop the last element off the array as that one will be your extension. <?php $file = "/some/path/to/your.file_stored_here.txt"; $extension = array_pop(explode(".", $file)); ?> $extension = 'txt' you could further use this with basename to strip off the extension completely off the file... <?php $file = "/some/path/to/your.file_stored_here.txt"; $extension = array_pop(explode(".", $file)); $filename = basename($file, ".$extension"); ?> $extension = 'txt' $filename = 'your.file_stored_here'

« previous php.notes (#140450) next »