There is a code that looks for a number in the file, and deletes it if it is present, and if not, it does nothing:
$key = $_REQUEST['del']; $filename = 'list.txt'; $lines = file($filename); $output = ''; foreach ($lines as $line) { if (!strstr($line, $key)) { $output .= $line; } } file_put_contents($filename, $output); But problems arise when the number 11 or 15 is allowed in the file and when you try to delete the number 1, which is not there, both 11 and 15 are deleted (that is, everything starts with 1). How to make so that only exact number was deleted? Tried to change strstr to preg_match, did not work ...