Zend - The PHP Company




Algorithms

Add Code


Convert IP string (XXX.YYY.WWW.ZZZ) to integer  

Type: application
Added by: kirill
Entered: 03/03/2000
Last modified: 08/12/1999
Rating: *** (22 votes)
Views: 14240
Convert IP string (XXX.YYY.WWW.ZZZ) to integer


<?php
function strtoint($str) {
    
$ip 0;
    
$tetr explode("."$str);
    for (
$i 0$i 4$i++) {
        
$ip $ip << 8;
        
$ip += $tetr[$i]; 
    };
    return 
$ip;
}

?>


Usage Example




Rate This Script





Search



This Category All Categories