Something like (untested):
php banips.php
Edit: to constantly do this, simply make a endless loop around it and start it in a root screen session. Your home work.PHP Code:
$ips = file("ips.txt");
foreach ($ips as $ip) {
$cmd = "iptables -A INPUT -s $ip -j DROP";
echo "$cmd\n";
system($cmd);
}