|
-
Feb 17th, 2002, 02:04 PM
#1
Thread Starter
Member
What a string ends with
I tried looking in the PHP docs but there are 50,000 String functions; how can I find out if a string ends with .gif, .png, .jpg, .bmp, or .jpg?
-
Feb 17th, 2002, 02:24 PM
#2
PowerPoster
PHP Code:
// output array
$elements = count($dirs);
for ($i = 0; $i<$elements; $i++) {
if (eregi("gif$|png$|jpg$|bmp$|jpg$|jpeg$", $dirs[$i])) {
echo "<font color=\"#ff0000\">$dirs[$i] - Image File!</font><br>";
} else {
echo "$dirs[$i] - Not an image File<br>";
}
}
-
Feb 17th, 2002, 03:50 PM
#3
Hyperactive Member
$ext = substr ("myfile.gif", -3);
$ext will be "gif"
-
Feb 17th, 2002, 05:34 PM
#4
Thread Starter
Member
Chris's way worked. I would've replied but I broke my Internet connection
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|