function to get file extentions

From: Date: Sat, 19 Nov 2005 23:31:49 +0000
Subject: function to get file extentions
Groups: php.mirrors 
Request: Send a blank email to php-mirrors+get-29795@lists.php.net to get a copy of this message
Hi, I was looking for a function to get the extention of a file in php 4 I don't know if php5 has something similar or not. Anyhow 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'); ?> I dont know any C++ yet so I just wrote it in PHP just to give an idea (if nobody has already thought of it). If it doesn't exist, then I think its well worth putting in as a construct or something. All the best Aktar Miah (www.servicetender.com)

« previous php.mirrors (#29795) next »