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

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -