dtqi87613
2013-08-12 22:20
浏览 214
已采纳

将开始和结束ip范围转换为网络掩码

Good morning,

I am trying to get the subnet mask from a start and end ip in PHP.

Eg;
14.1.32.0 and 14.1.64.0 is 255.255.224.0

But there doesn't seem to be any built in function for this? Everything I have searched refers to CDIR and trying to get all the ips etc so it seems I am trying to go the other way.

Anyone have any ideas?

图片转代码服务由CSDN问答提供 功能建议

早上好,

我正在尝试从中获取子网掩码 用PHP开始和结束ip。

 例如; 
14.1.32.0和14.1.64.0是255.255.224.0 
   
 \  n 

但似乎没有任何内置功能吗? 我搜索的所有东西都指的是CDIR并尝试获取所有的ips等所以看起来我试图走另一条路。

任何人都有任何想法?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • drhs13583567608 2013-08-12 22:24
    已采纳

    This should get you what you want:

    $ip = "14.1.32.0"; 
    $ip2 = "14.1.64.0";
    echo long2ip(ip2long($ip) - ip2long($ip2));
    
    点赞 评论

相关推荐 更多相似问题