一个php问题求助
<?php
if(isset($_POST["txt"])){
$files=glob('cache/text/*');
foreach($files as $file){
if(strstr($file,"32722")) continue;
unlink($file);
}
echo "清除成功!<br/>";
}
echo '<form action="admin.php" method="post">
<input type="text" name="txt" /> <input type="submit" value="清除" />
</form>' ?>
加入我要删除cache/text/文件夹下包含post提交字符的说有文件,比如输入框输入72637,就要删除cache/text/底下包含这个数字的所有文件,该怎么改????
if(isset($_POST["txt"])) {
$i = 0;
$files=glob('cache/text/*');
foreach($files as $file) {
if(false !== strpos($file, $_POST['txt'])) {
unlink($file);
$i++;
}
}
echo "清除成功!共清除{$i}个。<br/>";
}
echo '<form action="admin.php" method="post">
<input type="text" name="txt" /> <input type="submit" value="清除" />
</form>';
?>
@红袖