Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added ip2double. This will return a PHP double instead of a long, sol…

…ving

the signed long problem.


git-svn-id: http://svn.php.net/repository/pear/packages/Net_IPv4/trunk@132918 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information...
commit 439a7a405ddcd8e9dbfcc6c2efa49f9a8221e9ee 1 parent 7ed3c2e
Eric Kilfoil authored
Showing with 8 additions and 0 deletions.
  1. +8 −0 IPv4.php
View
8 IPv4.php
@@ -289,6 +289,14 @@ function htoa($addr)
}
return(FALSE);
}
+ /**
+ * Converts an IP address to a PHP double. Better than ip2long because
+ * a long in PHP is a signed integer.
+ */
+ function ip2double($ip)
+ {
+ return((double)(sprintf("%u", ip2long($ip))));
+ }
}
?>
Please sign in to comment.
Something went wrong with that request. Please try again.