|
|
| Author |
Message |
G-Bomb
Joined: 29 Feb 2004 Posts: 73
|
Posted: Mon Mar 01, 2004 1:15 am Post subject: Converting an IP address into decimal form. (PHP) |
|
|
Sometimes it's necessary to use the decimal form of an IP address. This little PHP snipplet does it for you.
| Code: | function IP2long($IP) //Convert an IP (xxx.xxx.xxx.xxx) into its decimal form
{
$Dec = 0.0; //force to work with double (32bits)
$val = explode('.', $IP);
for ($i=0; $i<count($val); $i++)
{
$Dec = ($Dec *256.0); //force to work with double
$Dec+=($val[$i]*1.0); //force to work with double
}
Return $Dec;
} |
|
|
| Back to top |
|
 |
sam Banned
Joined: 01 Mar 2004 Posts: 51 Location: IL
|
Posted: Mon Mar 01, 2004 1:24 pm Post subject: |
|
|
NICE  _________________
 |
|
| Back to top |
|
 |
macabist Banned
Joined: 01 Mar 2004 Posts: 35
|
Posted: Mon Mar 01, 2004 1:35 pm Post subject: |
|
|
THX
I will try it. |
|
| Back to top |
|
 |
|