I use this function and Its Fine on Local means when $hexIpStr exist function return false otherwise return true,
But when I Deploy my Project on Server this Function only Return True,
$arr is 2D array.
function ipChecker($arr, $hexIp)
{
$hexIpStr = "HEX=" . $hexIp;
foreach ($arr as $members) {
if (in_array($hexIpStr, $members)) {
return false;
} else {
return true;
}
}
}
The function is for example called with these values:
$hexIp = 'f528764d624db129b32c21fbca0cb8d6';
$arr = array(
0 => [
0 => 'FullName=mehdi',
1 => '[email protected]',
2 => 'IP=127.0.0.1',
3 => 'HEX=f528764d624db129b32c21fbca0cb8d6',
4 => '=>',
5 => 'Opinion=1 ',
],
1 => [
0 => '',
],
);
no its not answer because its fine in the server i get this
FullName=asd [email protected] IP=192.119.160.197 HEX=dd029394f038b0775138a23df8d9cddd => Opinion=1 and its right and i use this function to get user ip:
function GetRealIp()
{
if (!empty($_SERVER['HTTP_CLIENT_IP'])) //check ip from share internet
{
$ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) //to check ip is pass from proxy
{
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$ip = $_SERVER['REMOTE_ADDR'];
}
return $ip;}
$hexIpStrholding the data is not found in the array$members.var_dump($hexIpStr);andvar_dump(members);to check if$hexIpStris actually found in the arraymembers.var_dump()on the server ? (should not be done on the local as it is working fine there). With the code above, the only reason it is returning true it because the$hexIpStris not present in$members.$arroutput here.