note 58940 deleted from index by dmytton

From: Date: Mon, 21 Nov 2005 17:14:07 +0000
Subject: note 58940 deleted from index by dmytton
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-98891@lists.php.net to get a copy of this message
Note Submitter: aktar at servicetender dot com ---- I have noticed that PHP doesn't have a function or construct for getting the file extension. I made a very simple function to settle that problem. <? function get_ext ($filename) { $dismantle = explode(".", $filename); $segments = count($dismantle); $ext = $dismantle[$segments-1]; return (empty($ext) ? 'invalid' : $ext); } //USAGE : get_ext ( str filename) echo get_ext('aktar.php'); ?> NOTE : if you use this function as is then you should be aware that an invalid file extension will return the word 'invalid'

« previous php.notes (#98891) next »