问个问题
现在要实现IP模糊查询
意思也就是比如我现在输入
192.168.1.*
那么就要查出192.168.1.0~192.168.1.255中的所有IP
输入192.168.*.1
就要查出192.168.0.1~192.168.255.1中的所有IP
说的要用二进制与或运算可以实现,哪个给我指点一下

解决方案 »

  1.   

    <?php 
    $start = ip2long('192.168.1.1');
    $start = sprintf("%u", $start) ;
    $end = ip2long('192.168.1.50');
    $end = sprintf("%u", $end) ;
    for ($start; $start<$end; $start++){
        echo long2ip($start)."<br>";
    }
    ?>
      

  2.   

    //开始IP
    $sip=str_replace("*","1",$ip);
    //结束IP
    $eip=str_replace("*","255",$ip);
    //接着用一楼的方法就行了