Results 1 to 4 of 4

Thread: What a string ends with

  1. #1

    Thread Starter
    Member filburt1's Avatar
    Join Date
    Aug 1999
    Posts
    6,935

    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?

  2. #2
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    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>";
        }


  3. #3
    Hyperactive Member thinktank2's Avatar
    Join Date
    Nov 2001
    Location
    Arctic
    Posts
    272
    $ext = substr ("myfile.gif", -3);

    $ext will be "gif"

  4. #4

    Thread Starter
    Member filburt1's Avatar
    Join Date
    Aug 1999
    Posts
    6,935
    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
  •  



Click Here to Expand Forum to Full Width