note 68563 added to function.explode

From: Date: Wed, 02 Aug 2006 02:21:31 +0000
Subject: note 68563 added to function.explode
Groups: php.notes 
Request: Send a blank email to php-notes+get-115432@lists.php.net to get a copy of this message
A simple way to extract a file extension using explode: <?php function get_ext($file) { $parts = explode(".",$file); // If there is no extension function returns false if (count($parts) <= 1) { return false; } // Returns the extension if there is one else { return strtolower($parts[count($parts)-1]); } } ?> Note that this function allows the file to have extra dots before the "final extension". Something like "my.file.doc" would have ".doc" as a result. Extensions are converted to lowercase using strtolower(). ---- Server IP: 66.163.161.117 Probable Submitter: 201.37.173.207 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.explode.php Edit -- https://master.php.net/note/edit/68563 Del: integrated -- https://master.php.net/note/delete/68563/integrated Del: useless -- https://master.php.net/note/delete/68563/useless Del: bad code -- https://master.php.net/note/delete/68563/bad+code Del: spam -- https://master.php.net/note/delete/68563/spam Del: non-english -- https://master.php.net/note/delete/68563/non-english Del: in docs -- https://master.php.net/note/delete/68563/in+docs Del: other reasons-- https://master.php.net/note/delete/68563 Reject -- https://master.php.net/note/reject/68563 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#115432) next »