Solution to files containing partial strings in PHP

zhaozj2021-02-16  54

There are many files in this folder, and the suffix is ​​uncertain.

The front unification of the file name of the file to be deleted is the beginning of F165. For example: f165d3.gif, f16532.zip, etc.

-------------------------------------------------- -------------

$ D = DIR ("directory name");

While ($ f = $ d-> read ($ d)) {

IF (preg_match ("/ ^ f165. * /", $ f))

Unlink ($ D-> Path. "/". $ f;

}

$ D-> Close ();

转载请注明原文地址:https://www.9cbs.com/read-19187.html

New Post(0)