note 77712 deleted from function.basename by googleguy
| From: | googleguy@php.net | Date: | Sat, 12 Jan 2013 09:48:12 +0000 |
| Subject: | note 77712 deleted from function.basename by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-192966@lists.php.net to get a copy of this message | ||
Note Submitter: mike at mike-griffiths dot co dot uk
----
If you are trying to get the file extension of a given file then you should see the function
pathinfo(), exploding by '.' on basename() is also possible (as long as you use the last
array entry).
<?PHP
// Make an array of the various attributes
$path_parts = pathinfo('/www/htdocs/index.html');
$extension = $path_parts['extension'];
echo $extension; // 'html'
?>
Hope this helps someone.