Free Web Hosting PHP/mySQL
GlobalWeb.com.ru Forum Index GlobalWeb.com.ru
Free Web Hosting :: Commercial Web Hosting :: PHP/mySQL :: CGI/Perl
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Converting an IP address into decimal form. (PHP)

 
Post new topic   Reply to topic    GlobalWeb.com.ru Forum Index -> Howtos
Author Message
G-Bomb



Joined: 29 Feb 2004
Posts: 73

PostPosted: Mon Mar 01, 2004 1:15 am    Post subject: Converting an IP address into decimal form. (PHP) Reply with quote

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
View user's profile Send private message
sam
Banned


Joined: 01 Mar 2004
Posts: 51
Location: IL

PostPosted: Mon Mar 01, 2004 1:24 pm    Post subject: Reply with quote

NICE Razz
_________________
Back to top
View user's profile Send private message Visit poster's website
macabist
Banned


Joined: 01 Mar 2004
Posts: 35

PostPosted: Mon Mar 01, 2004 1:35 pm    Post subject: Reply with quote

THX
I will try it.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    GlobalWeb.com.ru Forum Index -> Howtos All times are GMT
Page 1 of 1

 


Free Web Hosting, Commercial Web Hosting, PHP/mySQL Copyright © 2009
Free Scripts Directory | Free Software Downloads | Newsgroups Directory | Optel.net | Mirroraty | Cruised.net | Hardware Keylogger