IP addresses are not permanent which means if you add an IP address to your banned list, at some point that IP address could be recycled to a valid user and you could be blocking a user that may not be the original person you banned.
My IP address is different every time I log on to and use the internet.
So... if you are wanting to do this, I suggest that you use a database for speed and if you are not using mysql, then check to see if sqlite is present and use that as it increases speed of access and you would reduce your script down to a simple query.
Something like this...
$db = sqlite_open("bannedIPaddresses") or false;
if(!$db) header("Location: errorpage.php");
// run a query to find if the database has an IP address in it
$banned = sqlite_query($db, sqlite_escape_string( sprintf("SELECT * FROM banned WHERE bannedIP='%s' LIMIT 1;--",$_SERVER['REMOTE_ADDR']) ) );
// if we have a row returned then the database has a banned IP
if( sqlite_num_rows($banned)>0 ) header("Location: bannedpage.php");
So what is happening now is any bad IP addresses that are in the database are sent to another page leaving your regular page to be displayed.
You could add a date added so that your query can ignore any IP's added after a set time period.
I have a website which harvests IP addresses and records what URL was requested along with the time and date and it uses sqlite to do the job. I occasionally load up a viewer to look at the contents but I am too lazy to add a feature to calculate what URL is popular (page) and how often they are visited.
Anyway, I hope that this helps you on your way.