This is a second request on the same subject. I wasn't clear I needed the line to be deleted.
I searched here and found part of a script that is suppose search for a word and delete the line. There seems to be a slight error with what I'm trying to do.
I have an option list in a pull down. I would like for it to remove the line selected. The file choice.php that is called from the pull down page seems to be released when the php below is called called because there is no access denied, or violation errors.
These are the errors I'm getting after adding the 3 last lines I was told I need.
fopen() expects at least 2 parameters, 1 given
implode(): Invalid arguments passed
fwrite() expects parameter 1 to be resource, boolean given
fclose() expects parameter 1 to be resource, boolean given
Thanks in advance
<?php
// Separate choice.php has the following pull down
// Select item to delete from list
// <option value="item1.php">Item 1</option>
// <option value="item2.php">Item 2</option>
// ...... many items.
$workitem = $_POST["itemtodelete"];
$file = file("option.list.php");
foreach( $file as $key=>$line ) {
if( false !== strpos($line, $workitem) ) {
unset ($file[$key]);
}
}
// Removed "
"
$file = implode("", $file);
// Told to add this.
$fp = fopen ("option.list.php");
fwrite($fp,implode("",$file);
fclose ($fp);
?>