PHP 8.4.24 Released!

Voting

: min(one, four)?
(Example: nine)

The Note You're Voting On

mar dot czapla at gmail dot com
17 years ago
Here we have gr8 function which simply convert ip address to a number using substr with negative offset.
You can need it if you want to compare some IP addresses converted to a numbers. 
For example when using ip2country, or eliminating same range of ip addresses from your website :D

<?php

function ip2no($val)
{    
    list($A,$B,$C,$D)    =    explode(".",$val);
    return 
        substr("000".$A,-3).
        substr("000".$B,-3).
        substr("000".$C,-3).
        substr("000".$D,-3);
}

$min        =    ip2no("10.11.1.0");
$max        =    ip2no("111.11.1.0");
$visitor    =    ip2no("105.1.20.200");

if($min<$visitor && $visitor<$max)    
    {    echo 'Welcome !';    }
else    
    {    echo 'Get out of here !';    }

?>

<< Back to user notes page

To Top