Search files in directory with php

Free Scripts :: PHP :: Files and Folders :: Search files in directory with php

Author: Salman Javaid

Website: http://www.salman.be

  • How to search files of a directory with php.
  • search a file from a folder with php.

This script searches the files located in folder by matching keyword.

Script

$string_to_search='btn';
$path='pictures/products/';
$handle=opendir($path);

while (($file = readdir($handle))!==false){
    if ($file!="." && $file!=".."){
        if(strstr($file,$string_to_search)!==false){
            echo $file . ', ';
        }
    }
}

Output

btnDelete.gif, Previewbtn.gif

Comments

No comments. Be the first one.

Leave a comment

Full Name*
Comments*
Security Code*

Our Partners

Getty Icons  Salman Creations
Free High Quality Images  Learn Free Languages 
Opal Hosting  R-Tech Solutions
  • Submit a Script

    Click here to submit your script.