Delete files which has the same prefix

前端 未结 2 411
别那么骄傲
别那么骄傲 2020-12-09 15:46
$prefix = \'something_prefix\';
unlink($prefix.\'.*\');

the code above is not working, but I see some code like this below works just fine

2条回答
  •  旧巷少年郎
    2020-12-09 16:23

    Try this code:

    $mask = 'your_prefix_*.*';
    array_map('unlink', glob($mask));
    

    p.s. glob() requires PHP 4.3.0+

提交回复
热议问题