SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: GIF != gif

  1. #1
    SitePoint Enthusiast
    Join Date
    Feb 2005
    Posts
    53
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    GIF != gif

    hello here is my code
    PHP Code:
    $file 'pic.gif';
    $file substr(strrchr($file'.'),1);
    $okey = array("gif","jpg","bmp");
    for(
    $num 0;$num count($okey);$num++) {
    if (
    $file == $okey[$num]) {
    echo 
    $file.' = '.$okey[$num].'<br />';
    echo 
    "the result is: Good";
    break; } else {
    echo 
    $file.' != '.$okey[$num].'<br />';
    echo 
    "Bad file name "."<b>({$file})</b>";
    break;
    }

    my code is working fine put when i changed the $file = 'pic.GIF';
    the result : Bad file name (GIF)
    so how can i avoid this problem to make the Gif or GIF is the same as gif

    thanks

  2. #2
    SitePoint Zealot rain5017's Avatar
    Join Date
    Sep 2005
    Posts
    166
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $file 'pic.gif';
    $file strtolower(substr(strrchr($file'.'),1));
    $okey = array("gif","jpg","bmp");
    for(
    $num 0;$num count($okey);$num++) {
    if (
    $file == $okey[$num]) {
    echo 
    $file.' = '.$okey[$num].'<br />';
    echo 
    "the result is: Good";
    break; } else {
    echo 
    $file.' != '.$okey[$num].'<br />';
    echo 
    "Bad file name "."<b>({$file})</b>";
    break;
    }

    strtolower function

  3. #3
    SitePoint Enthusiast
    Join Date
    Feb 2005
    Posts
    53
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    rain5017

    the code still has the same problem when
    i changed the first line to ($file = 'pic.GIF')
    result is:
    GIF != gif
    Bad file name (GIF) !!

    and i think you want me to change
    if (strtolower($file) == $okey[$num])
    instead of
    if ($file == strtolower($okey[$num])
    and this is fixe it
    but my question php can not do this for me right ? the chr G not the same as g by defult
    ?

  4. #4
    SitePoint Zealot rain5017's Avatar
    Join Date
    Sep 2005
    Posts
    166
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by zaid
    the code still has the same problem when
    i changed the first line to ($file = 'pic.GIF')
    result is:
    GIF != gif
    Bad file name (GIF) !!

    and i think you want me to change
    if (strtolower($file) == $okey[$num]))
    instead of
    if ($file == strtolower($okey[$num]))
    and this is fixe it
    but my question php can not do this for me right ? the g char to the same as g by defult
    ?
    Sorry,I had maden a error ago,but now,I had edited the code.

    It should be $file = strtolower(substr(strrchr($file, '.'),1));

  5. #5
    SitePoint Enthusiast
    Join Date
    Feb 2005
    Posts
    53
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    nothing mattar

    i understood your idea,
    thank you rain5017


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •