php - Checking a file for a specific IP address? -
what i'm trying check file named ip-addresses.php
in same directory specific ip address , if ip not in file want assign value of spark
here have far:
$ip = if( $ip ) { $value = "spark"; } ?>
so i'm trying have value $ip
check php file ips , assign value of "spark"
how do this?
the function file()
reads lines of file array, making easy check existing elements in_array()
.
$list = file("ip-addresses.txt", file_ignore_new_lines | file_skip_empty_lines); if (in_array($_server['remote_addr'], $list)) { $value = "spark"; }
Comments
Post a Comment