Hello and thanks for reading my question about file handling with php.
Here's what I would like to do :eek:
I have a php file with an array of banned IP addresses that looks so....
<?php
BanIP['1'] = "116.18.66.206";
BanIP['2'] = "116.18.66.228";
BanIP['3'] = "116.18.67.78";
BanIP['4'] = "12.104.1.241";
BanIP['5'] = "12.110.20.22";
BanIP['6'] = "12.145.167.134";
BanIP['7'] = "12.147.151.38";
BanIP['8'] = "12.159.171.230";
BanIP['9'] = "12.162.39.217";
BanIP['10'] = "12.163.240.199";
?>
I have no problem reading the file and banning the offender, but I would like to be able to add to the file.
I can't seem to use the append unless I'm using it incorrectly
$fp = fopen($f,'a');
fwrite($fp,"$log\n");
fclose($fp);
what appears to happen is the new entry is added after the "?>"
Is there a way to read the file unil it sees "?>" Then have it to to a previous line insert a line
BanIP['11'] = "120.1.241.1";
?>
Thanks for any help