note 81386 added to function.filetype
| From: | rich dot fleming at NOSPAM dot gmail dot com | Date: | Tue, 26 Feb 2008 03:08:32 +0000 |
| Subject: | note 81386 added to function.filetype | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-136485@lists.php.net to get a copy of this message | ||
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'
----
Server IP: 69.147.83.197
Probable Submitter: 76.71.29.98
----
Manual Page -- http://www.php.net/manual/en/function.filetype.php
Edit -- https://master.php.net/note/edit/81386
Del: integrated -- https://master.php.net/note/delete/81386/integrated
Del: useless -- https://master.php.net/note/delete/81386/useless
Del: bad code -- https://master.php.net/note/delete/81386/bad+code
Del: spam -- https://master.php.net/note/delete/81386/spam
Del: non-english -- https://master.php.net/note/delete/81386/non-english
Del: in docs -- https://master.php.net/note/delete/81386/in+docs
Del: other reasons-- https://master.php.net/note/delete/81386
Reject -- https://master.php.net/note/reject/81386
Search -- https://master.php.net/manage/user-notes.php