Faced with such a problem: there is a file that contains a string list of information, that is:
1 2 3
etc. I need to display checkboxes next to them in php so that I can mark and delete the line. How can this be done?
Faced with such a problem: there is a file that contains a string list of information, that is:
1 2 3
etc. I need to display checkboxes next to them in php so that I can mark and delete the line. How can this be done?
<?php $file = 'ya.txt'; if(isset($_POST['nums'])) { $array = file('ya.txt'); if(is_array($_POST['nums'])) { foreach($_POST['nums'] as $ArrList) { unset($array[$ArrList]); } } file_put_contents($file, implode("", $array)); die("Файл сохранен!"); } $array = file($file); echo "<form method='post'>"; foreach($array as $ArrNum => $ArrList) { echo "<label><input type='checkbox' name='nums[]' value='$ArrNum'> $ArrList</label><br>"; } echo "<input type='submit' value='Обновить'></form>";
This is elementary, Watson:
<?php $f=file("file.txt"); foreach ($f as $key=> $value) { print "<input type='checkbox' name='del_$key' value='$value'>"; } ?>
Then implement file overwriting without unnecessary lines or search with deletion.
And can each line be made an element of the array?
Source: https://ru.stackoverflow.com/questions/172179/
All Articles