Get certain files from a directory using glob() - PHP -


basically want files directory using glob(). file format this:

052013.www.test1.com.txt 052014.www.test1.com.txt 062014.www.test1.com.txt 072014.www.test1.com.txt 082014.m.test1.com.txt 092014.test1.com.txt 

and file of curent year (i.e $_session['year']) , has www or m in it, here's function :

function get_files(){     $dir = document_root;     $hostname = host;     $files = array();     $scan = glob($dir."{*".$_session['year'].".m.,*".$_session['year'].".www.}".$hostname.".txt", glob_brace | glob_nocheck );     foreach ( $scan $file ) {       $files[] = $file;     }     return $files; } 

the issue here when doesn't found file has example www returns :

array (     [0] => /var/www/stats/082014.m.test1.com.txt     [1] => /var/www/stats/*2014.www.test1.com.txt ) 

what's mistake i'm making in function here? appreciated.

glob_nocheck - return search pattern if no files matching found

you can remove glob_nocheck , if there no "www" files glob function not return pattern in result array.


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -