Sunday, 28 August 2016

How to fetch all files name from folder in PHP


Fetch all files name from folder in PHP

    if ($handle = opendir("C:\wamp\www\yoursite/download/")) {

            while (false !== ($entry = readdir($handle))) {
                if ($entry != "." && $entry != "..") {
                   
                        echo "<b>".preg_replace('/\\.[^.\\s]{3,4}$/', '', $entry)."</b>";
                   
                }
            }

        closedir($handle);
    }

Thats it.... Enjoy Chandresh rana's Coding... :)

1 comment:

Anonymous said...

Could you explain what the pre_greplace is doing?