Hello all,
I am looping through a list of files in a directory and I want to match a substring that I have with the filename. If the filename contains the substring then return that file name so that I can delete it. I have done the following and its just returning everything:
while ($file = readdir($dir_handle)) {
$extension = strtolower(substr(strrchr($file, '.'), 1));
if($extension == "sql" || $extension == "txt" ) {
$pos = strpos($file, $session_data['user_id']);
if($pos === true) {
//unlink($file);
echo "$file<br />";
}else {
// string not found
}
}
}
What am I doing wrong?
Thanks all for any help