I have been banging my head up the wall with this bit of code which really should work but doesn't:
Code: Select all
if(false !== ($index = array_search($email,$list))) {
unset($list[$index]); // unset an array index and re-index the array
$temp=array_values($list);
$list=$temp;
$handle2=fopen("email_list2.txt","x+"); // create and prepare a file to be written to
foreach($list as $val){ // write the array to the file
fwrite($handle2, $val, strlen($val));
}
fclose($handle2);
unlink("email_list.txt");
rename("email_list2.txt","email_list.txt");
}Any help would be appreciated.
Thanks,
Rob.