How to convert an IP address to IPCDBL

Source: Internet
Author: User
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;}?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.