Re: read last three letters

From: Date: Tue, 28 May 2002 21:20:34 +0000
Subject: Re: read last three letters
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-99573@lists.php.net to get a copy of this message
Why not do something like: if( file_exists("$c.gif") { // show the gif }else if( file_exists("$c.jpg") ) { // show the jpeg } else // freak out } On Wed, 29 May 2002, r wrote: > Hi PHP ppl, > > I have a directory named cartoons, > it has around 180 files in them ONLY images, > the filenames are 1.jpg, 2.jpg......5.gif, 6.gif etc etc > if you got confused with the above line its basically all the files are > numbered from 1-180 and the file types are mixed JPG and > GIF. > > I have a program that displays each of the cartoons displays a <-- Prev * > * * Next--> link, basicaly theres a hidden field that specifies the current > number and if you click prev its c=c-1 and if your press next its c=c+1, but > I have no idea if the next cartoon is either JPG or GIF and so am displaying > both like so in my code: > > <img src=$c.gif> > <img src=$c.jpg> > since only one is valid the other shows an ugly blank image placeholder > graphic. > > Any idea on how i can read the last three letters of the file to determine > if its gif/jpg? > > Kindly reply, > -Ryan. > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.general (#99573) next »