Searching search files



  • Help me write a function that will remove a list of files from the directory that contain the word sought. The Directory and the word sought are presented as the parameters of the function.



  • function f($dir, $name, $exclude_dir = true) {
    return array_filter(scandir($dir), function ($i) use ($exclude_dir, $name) {
        if ($exclude_dir && is_dir($i)) return false;
        return substr_count($i, $name);
    } );}
    

Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2