Announcement

Collapse
No announcement yet.

Extension Check

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Extension Check

    Need a little help writing an if statement to check if a certain file with the following extension is present.

    PHP Code:
    if(file_exists("/" . * . ".jpg")) 
    I realize php cannot use * as a wild card character, but was just curious as to how someone would use a wildcard file name with a .jpg extension this this statement.
    Trent Gillespie Mod Theater Gillespie Photography

  • #2
    PHP Code:
    function getext($f) {
     
    $ext substr($fstrrpos($f,".") + 1);
     return 
    $ext;

    getext('myfile.jpg'); should return jpg


    PHP Code:
    if(getext('myfile.jpg') == 'jpg') {
    echo 
    'this is an image file';

    That's the end of that!

    Comment


    • #3
      I knew how to break it up in a string, but just didnt know the func to read/scan a directory. Filburt at vB.org refered me to the readdir function and all was well
      Trent Gillespie Mod Theater Gillespie Photography

      Comment

      widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
      Working...
      X