note 21540 deleted from function.basename by spic
| From: | spic@php.net | Date: | Tue, 17 Sep 2002 09:05:13 +0000 |
| Subject: | note 21540 deleted from function.basename by spic | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-36775@lists.php.net to get a copy of this message | ||
// This is an alternate to php@silisoftware.com's post
// return extension function
function getext($filename) {
$f = strrev($filename);
$ext = substr($f, 0, strpos($f,"."));
return strrev($ext);
}
//Load test array
$filename[] = "yes.jpg";
$filename[] = "no.gif";
$filename[] = "maybe.jpeg";
$filename[] = "index.php";
$filename[] = "index.html";
$filename[] = "index.html.bak";
foreach($filename as $file) {
$extension = getext($file);
echo "$extension : ";
}
this will output jpg : gif : jpeg : php : html : bak :