Skip to content
/ Inet Public

A PHP implementation of decimal IPs. Converts IPs from presentation to decimal and viceversa. Very useful to store IPs in database as numbers instead of string, in example in a decimal(39,0) column.

Notifications You must be signed in to change notification settings

FoolCode/Inet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

Foolz\Inet

This Composer package provides two functions that allow converting between IP Address and IP Decimal. It works for both IPv4 and IPv6.

Based on the answer to "How to convert IPv6 from binary for storage in MySQL?" on StackOverflow by Sander Marechal. Content posted on StackOverflow is under the CC BY-SA 3.0 License.

Requirements

Usage

$decimal_ip = \Foolz\Inet\Inet::ptod($ip);
$ip = \Foolz\Inet\Inet::dtop($decimal_ip);

Storage on MySQL Databases

You should use a DECIMAL(39,0) column to store the entire IP Decimal.

About

A PHP implementation of decimal IPs. Converts IPs from presentation to decimal and viceversa. Very useful to store IPs in database as numbers instead of string, in example in a decimal(39,0) column.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages