<html>
<head>
<title>Week #10 test ~ Lestat</title>
<link rel="stylesheet" type="text/css" href="/css/scriptskewl.css">
</head>
<body>

<?
// 
$file_contents = array('cat@dog.com','pepsi@soda.com','dog@cat.com');
?>
<form method="POST" action="test.php">
<?
foreach($file_contents as $key=> $value){
    print(
"$value <input type=\"checkbox\" name=\"todelete[$key]\" value=\"$value\"> ");
}
?>

<input type="submit" value="Submit">
</form>
<?php
// show checkbox results BEFORE splice
$arrToDelete $_POST['todelete'];
if(
$arrToDelete != "") {
    
print_r($file_contents);
    print 
'<hr>';
    foreach(
$arrToDelete as $key => $value) {
        
array_splice($file_contents$key1"");
    }
}

// show checkbox results AFTER splice (now you have a dead element to remove)
if($_POST['todelete'] != "") {
    
print_r($file_contents);
}
?> 












<pre>



</pre>


<a href='../index.html'>Index</a>

<br>
<iframe src='testsrc.php' width='100%' height='300'></iframe>
<br>

<a href='../index.html'>Index</a>

</body>
</html>