How do I convert an IP address to IPCDBLip and an IP address to IPCDBL? For example, after 192.168.1.255 is converted to 3232236031, find the algorithm for converting ip to ipcdbl and the algorithm for converting ipcdbl to ip, PHPcode & lt ;? Phpfunctioniptolong ($ ip) {$ key = explode ('.', how to convert an ip address to IPCDBL
How do I convert an IP address to IPCDBL?
For example, after 192.168.1.255 is converted to 3232236031,
Algorithm for converting ip address to ipcdbl and ipcdbl to ip address
------ Solution --------------------
PHP code
= 4) {$ long = intval ($ key [0]) * 16777216 + intval ($ key [1]) * 65536 + intval ($ key [2]) * 256 + intval ($ key [3]);} return $ long;} function longtoip ($ long) {$ long = floor ($ long ); $ p4 =long long-floor ($ long/256) * 256; $ long = ($ long-$ p4)/256; $ p3 = $ long-floor ($ long/256) * 256; $ long = ($ long-$ p3)/256; $ p2 = $ long-floor ($ long/256) * 256; $ long = ($ long-$ p2)/256; $ p1 = $ long; $ ip = $ P1. '.'. $ p2. '.'. $ p3. '.'. $ p4; return $ ip;}?>