|
Posted by Ron Eggler @ work on 06/20/05 13:19
Ron Eggler @ work wrote:
> [snip]
>> If it still doesn't
>> work, I don't know what will...
>
> oh very bad because it doesn't work...: :( I pasted the Code below....
>>
>> This from the manual, the chaper about variable scope: "In PHP global
>> variables must be declared global inside a function if they are going
>> to be used in that function."
>
> yup, and the code looks like this:
> [Code]
> //at the top of the file:
> $blacklist="blacklist.txt";
>
//--------------------------------------------------------------------------
> ----
> function removeEMail($email_address)
> {
> global $blacklist;
> // 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\n", 512);
> fclose($handler);
> }
> echo $email_address." removed from ". $blacklist ."<br>\n";
> }
> [/Code]
oh now I see when writing the array back to file it adds about 16 empty
returns between every address... :( why that?
[Back to original message]
|