note 21543 deleted from function.stristr by victor
| From: | victor@php.net | Date: | Wed, 02 Oct 2002 10:32:10 +0000 |
| Subject: | note 21543 deleted from function.stristr by victor | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-37527@lists.php.net to get a copy of this message | ||
// A function to return the extension of a file
// 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 :