Block Spam comments using PHP code

The following code is from official WordPress.org

< ?php
$block = array("xxx.xxx.xxx.xxx", "yy.yy.y.yyy");

if (in_array ($_SERVER[‘REMOTE_ADDR’], $block)) {
header(“Location: http://google.com/”);
exit();
}
?>

I’ve added the read from file function and store the values into the array.
The following code will check the IP does it existing in the array, if the IP is exist,
then will redirect to Hong Kong Police Force web page 😛

< ?php
$block = file("block_list_ip.csv", FILE_SKIP_EMPTY_LINES);

if (in_array ($_SERVER[‘REMOTE_ADDR’], $block)) {
header(“Location: http://www.police.gov.hk/ppp_en/index.html”);
exit();
}
?>