otuatail Posted July 21, 2006 Share Posted July 21, 2006 Is there a full list of functions from a to z regardless of string or numeric? I spent ages writing ip2long() it is there already. But this is confusing me. I am trying to test if an IP address is within a range of 2 others. I should get "IN" not "OUT"$bl = '68.0.0.0';$tl = '68.255.255.255';$ip = '68.142.250.142';// function ipband()$btm = ip2long($bl);$top = ip2long($tl);$val = ip2long($ip);$pos = "OUT";if ($ip >= $btm && $ip <= $top){ $pos = "IN";}// return $pos;echo($pos . "<br><br>");Desmond. Link to comment https://forums.phpfreaks.com/topic/15236-ip-address-limmits/ Share on other sites More sharing options...
chrisprse Posted July 21, 2006 Share Posted July 21, 2006 How about trying:[code=php:0]<?php$bl = "68.0.0.0";$tl = "68.255.255.255";$ip = "68.142.250.142";$bl = str_replace('.', '', $bl);$tl = str_replace('.', '', $tl);$ip = str_replace('.', '', $ip);if(($ip >= $bl) && ($ip <= $tl)) { echo "IP is in range...";}else { echo "IP is not in range...";}?>[/code]hth Link to comment https://forums.phpfreaks.com/topic/15236-ip-address-limmits/#findComment-61568 Share on other sites More sharing options...
otuatail Posted July 21, 2006 Author Share Posted July 21, 2006 If I replace the $btm $top $val with there long values it works i.e.if (1150220942 >= 1140850688 && 1150220942 <= 1157627903){ $pos = "IN";} Link to comment https://forums.phpfreaks.com/topic/15236-ip-address-limmits/#findComment-61571 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.