You can loop over files you have checked using phps foreach
loop.
Here's example for that kind of delete script:
$path_to_folder = "folder/";
foreach ($_POST['select[]'] as $file) {
if(file_exists($path_to_folder . $file))) {
unlink($path_to_folder . $file);
}
elseif(is_dir($file)) {
rmdir($file); // or system("rm -rf " . escapeshellarg($dir));
}
}
echo "Files deleted successfully.";
And you better pass value from checkbox, not its id. Remember also add brackets to your input's name, because then php recognizes it as array.
<input name="select[]" type="checkbox" class="select" value="'.$file.'"/>
See more on this question: How do I recursively delete a directory and its entire contents (files + sub dirs) in PHP?