Can you help me understand why my last ip2long is empty?

Viewed 26

I've been fighting for hours ...

i want to understand if my ip is included in a list of ip ranges.

The list comes from a file, I do a foreach and an if

if(ip2long($_SERVER['REMOTE_ADDR']) >= ip2long($start) && ip2long($_SERVER['REMOTE_ADDR']) <= ip2long($end)){
    echo 'found';
}

...and it doesn't work...

I think the reason is this, if in my foreach I add this:

echo '<br>my '.$_SERVER['REMOTE_ADDR'].' - start '.$start.' - end '.$end.' --- my long '.ip2long($_SERVER['REMOTE_ADDR']).' - start long '.ip2long($start).' - end long '.ip2long($end);

The result I get looks like this:

my 146.241.156.220 - start 146.241.0.0 - end 146.241.255.255 --- my long 2465307868 - start long 2465267712 - end long
my 146.241.156.220 - start 1.6.0.0 - end 1.7.255.255 --- my long 2465307868 - start long 17170432 - end long
my 146.241.156.220 - start 1.22.0.0 - end 1.23.255.255 --- my long 2465307868 - start long 18219008 - end long
my 146.241.156.220 - start 1.38.0.0 - end 1.39.255.255 --- my long 2465307868 - start long 19267584 - end long
my 146.241.156.220 - start 1.186.0.0 - end 1.187.255.255 --- my long 2465307868 - start long 28966912 - end long 

Where did "end long" go? ip2long($end)

$end exists, works, but ip2long($end) is empty...

Why? What? Where? Who?

I've been fighting with this for hours, and something just isn't working, can you help me get out of this mess?

0 Answers
Related