Results 1 to 5 of 5
  1. #1

    Question Looking for a PHP function..

    I need a PHP function the sees if a file exists, within a certain pattern;

    I looked at PHP.net and they have glob() and another function, but neither work... help pls? Thanks.

  2. #2
    Join Date
    May 2002
    Location
    UK
    Posts
    2,994
    It's a function called file_exists()

    http://www.php.net/manual/en/function.file-exists.php

  3. #3
    uh.... sorry if I didn't make myself clear... I need to use it with foreach(). Foreach() can't use file_exists().
    www.jportalhome.com

  4. #4
    Join Date
    Jul 2002
    Location
    Israel
    Posts
    351
    Umm.

    PHP Code:
    $dir opendir('.') or die("Couldn't open directory.");
    $pat "/\.php$/i";
    while((
    $f=readdir($dir))!==false)
    {
      if (
    $f=='.'||$f=='..') continue;
      if (
    preg_match($pat,$f)) printf("%s\n",$f);
    }
    closedir($dir); 
    C#/C++/TCL/Python/PHP developer.
    mark at mark org il

  5. #5
    TIGHT!!! Thanks
    www.jportalhome.com

Posting Permissions

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