int2quad

code snippet for php3

   Converts a number to a dotted quad.  A google search revealed a similar
code-snippet which was close, but didn't work. This is the corrected version.

   This function is available as long2ip in php4.  



#
# converts an IP address in 32-bit form to a dotted-quad IP form
# 
function int2quad($int) {
        for ($i=0; $i<=3; $i++) {
                $array[$i] = intval(($int / pow(256,(3-$i))));
                $int = $int - ($array[$i] * pow(256,(3-$i))); 
        }
        return implode('.',$array);
}


Gerald Swann
16 July 2001