Re: [phplib] Extension of Files From: andreas otto (andreas <email protected>)
Date: 07/07/00

hi jose,

> I want to know if a file ($f) is an image file; i try to extract the
> extension (.gif or .jpg) of this file but i don't know how i can do
> it.

try regular expressions:

<?php

$doc_name = "another-nice-image.gif";
$doc_type_image = ereg("(gif$|jpg$|psd$)",$doc_name);

if ($doc_type_image == 1){
?>
the document is an image...
<?php
}

?>

the above example looks IF $doc_name ENDS with gif OR jpg OR psd and
writes the result in $doc_type_image.

if you want to learn more about regular expressions have a look at [
www.devshed.com ] they have a tutorial about regular expressions on
their site.

cheers,
andreas

--
Andreas Otto
OgilvyInteractive | Floor 2, Canberra House
315 - 317 Regent Street | London W1B 2HS
Reception +44 207 299 3434 | Fax +44 207 631 5050
http://www.ogilvy.com

--------------------------------------------------------------------- To unsubscribe, e-mail: phplib-unsubscribe <email protected> For additional commands, e-mail: phplib-help <email protected>