PHP – Delete files which has the same prefix

You can use glob and array_map function like below:

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

p.s. glob() requires PHP 4.3.0+

You can also use glob for this. Something like this(didn’t test it):

foreach (glob("something_prefix*.*") as $filename) {
    unlink($filename);
}