Hi i have stored some file names in mongodb and i stored some files in my local directory, now my requirement is to extract the local path of the file which matches to the value in the db exactly it should not match a particular string in the file it should match with complate string. can u please suggest me how to do this.
example: sample-php-book.pdf
is the db value it should match with sample-php-book.pdf
file name not with sample.pdf
i have used the following code
<?php
$results = array();
$directory = $_SERVER['DOCUMENT_ROOT'].'/some/path/to/files/';
$handler = opendir($directory);
while ($file = readdir($handler)) {
if(preg_match('$doc['filename']', $file)) {
$results[] = $file;
}
}
}
?>
$doc[filename] is the value from db
Thanks