HTML beginner |
|
Citaat: Identical to readfile(), except that file() returns the file in an array. Each element of the array corresponds to a line in the file, with the newline still attached. Upon failure, file() returns FALSE.
Van http://nl2.php.net/manual/en/function.file.php
De IP's staan dus zo in de array
"127.0.0.1\n"
Dus je moet het of zo doen
<?php
$array = file('ip.txt');
if(in_array($_SERVER['REMOTE_ADDR']."\n", $array))
{
//toegang
}
else
{
//geen toegang
}
?>
<?php if(in_array($_SERVER['REMOTE_ADDR']."\n", $array)) { //toegang } else { //geen toegang } ?>
of zo doen
<?php
$file = file_get_contents( "ip.txt" );
$array = explode( "\n", $file );
if(in_array($_SERVER['REMOTE_ADDR'], $array))
{
//toegang
}
else
{
//geen toegang
}
?>
<?php if(in_array($_SERVER['REMOTE_ADDR'], $array)) { //toegang } else { //geen toegang } ?>
|