|
Posted by Ron Eggler on 06/18/05 14:54
Kimmo Laine wrote:
[snip]
> Hmm file_put_contents is fairly new function, available since PHP5.
> It is seems that you're running the script with older php.
yup, php 4.3.3
> Doesn't
> matter, that's just a shortcut for:
>
> if(@$handler = fopen("emails.txt","w")){
> foreach($emails as $line) fputs($handler, "$line\r\n", 512);
> fclose($handler);
> }
But following function doesn't remove the passed string ($email_address) out
of the textfile ($blacklist)
why not?
[Code]
function removeEMail($email_address)
{
// Read the file into an array. One address per row
$emails = file($blacklist);
// Remove given email address
unset($emails[array_search($email_address,$emails)]);
// Change array back to end-of-line separated string, write to file
if(@$handler = fopen($blacklist,"w"))
{
foreach($emails as $line)
fputs($handler, "$line\r\n", 512);
fclose($handler);
}
echo $email_address." removed from ". $blacklist;
}
[/Code]
and I still get following warning:
Warning: array_search(): Wrong datatype for second argument in
/srv/www/htdocs/web2/html/php/nospam/pop.php on line 31
how to remove it?
Thank you!
--
roN
www.rideon.ch
Navigation:
[Reply to this message]
|