Have you tried something like that ?
public function removeFilesOnDirectory($path)
{
$files = glob($path . '/*');
foreach ($files as $file) {
if(is_dir($file)) {
$this->removeDirectory($file);
} else {
if (str_contains($file, '2' /* Your constraint */)) {
unlink($file);
}
}
}
return;
}
Call this->removeDirectory(/* your path */);
Works for me, just testing it :)
Regards
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…