我这里有一个小问题我试图在数组中寻找一个特定的 ip 所以,如果这个 ip 退出我想返回 true 否则我想返回 false
但是,我尝试了很多方法,但它不起作用
我只是需要你的帮助,在此先感谢
function user_ip_exists($ip)
{
// ** Get Connection
open_handler();
$sql = sprintf(" SELECT `ip` FROM `answ` ");
$query = mysql_query($sql);
$database_ip = array();
for ($counter=0; $row = mysql_fetch_assoc($query); $counter++) {
foreach ($row as $key => $value) {
$database_ip[] = $value;
};
}
var_dump($database_ip);
}
// this the above var_dump
array (size=9)
0 => string '' (length=0)
1 => string '' (length=0)
2 => string '' (length=0)
3 => string '' (length=0)
4 => string '' (length=0)
5 => string ',127.0.0.1,127.0.0.1' (length=20) // ip address is separated with ' , '
6 => string '' (length=0)
7 => string '' (length=0)
8 => string '' (length=0)