ip地址和int相互转换 无 function ip_to_int($ip,$reverse=false){ if($reverse){ $ipVal = (int)$ip; $ipArr[0] = floor($ipVal / 0x1000000); $ipVint = $ipVal-($ipArr[0]*0x1000000); $ipArr[1] = ($ipVint 0xFF0000) 16; $ipArr[2] = ($ipVint 0xFF00 )
ip地址和int相互转换 11da01c6148ec3ec20c6fdc9adc31f96
function ip_to_int($ip,$reverse=false){ if($reverse){ $ipVal = (int)$ip; $ipArr[0] = floor($ipVal / 0x1000000); $ipVint = $ipVal-($ipArr[0]*0x1000000); $ipArr[1] = ($ipVint & 0xFF0000) >> 16; $ipArr[2] = ($ipVint & 0xFF00 ) >> 8; $ipArr[3] = $ipVint & 0xFF; $ipDotted = implode('.', $ipArr); return $ipDotted; } $ipArr = explode('.',$ip); $ipInt = ($ipArr[0] << 24) + ($ipArr[1] << 16) + ($ipArr[2] << 8) + ($ipArr[3]); return $ipInt; }