php代码-PHP代码ip2long 循环问题

问题描述

PHP代码ip2long 循环问题

代码:

 print_r($dataIp);
            foreach ($dataIp as $key=>$value) {
                $data['ip']     =   $value;
                $data['iplong']     =   bindec(decbin(ip2long($value)));
                print_r($data);
            }

显示结果
Array
(
[0] => 208.104.70.215
[1] => 74.101.176.171
[2] => 73.17.35.30
[3] => 70.198.197.3
[4] => 162.226.184.30
[5] => 142.167.132.139
[6] => 69.204.125.71
[7] => 76.77.139.72
[8] => 50.82.236.23
[9] => 68.197.139.155
[10] => 188.29.165.19
[11] => 92.14.251.192
[12] => 122.151.11.144
[13] => 2.122.114.91
[14] => 31.100.182.110
[15] => 199.7.157.11
[16] => 46.44.179.76
)
Array
(
[ip] => 208.104.70.215
[iplong] => 0
)
Array
(
[ip] => 74.101.176.171
[iplong] => 0
)
Array
(
[ip] => 73.17.35.30
[iplong] => 0
)
Array
(
[ip] => 70.198.197.3
[iplong] => 0
)
Array
(
[ip] => 162.226.184.30
[iplong] => 0
)
Array
(
[ip] => 142.167.132.139
[iplong] => 0
)
Array
(
[ip] => 69.204.125.71
[iplong] => 0
)
Array
(
[ip] => 76.77.139.72
[iplong] => 0
)
Array
(
[ip] => 50.82.236.23
[iplong] => 0
)
Array
(
[ip] => 68.197.139.155
[iplong] => 0
)
Array
(
[ip] => 188.29.165.19
[iplong] => 0
)
Array
(
[ip] => 92.14.251.192
[iplong] => 0
)
Array
(
[ip] => 122.151.11.144
[iplong] => 0
)
Array
(
[ip] => 2.122.114.91
[iplong] => 0
)
Array
(
[ip] => 31.100.182.110
[iplong] => 0
)
Array
(
[ip] => 199.7.157.11
[iplong] => 0
)
Array
(
[ip] => 46.44.179.76
[iplong] => 774681420
)
只有最后一个转换成功了,其他的都失败了,这是什么原因?

解决方案

http://blog.163.com/metlive@126/blog/static/1026327120104232330131/

时间: 2024-09-11 14:31:45

php代码-PHP代码ip2long 循环问题的相关文章

qt-用QT写了一个0槽和信号相关的代码,代码编译成功,但是槽函数始终接收不到信号,

问题描述 用QT写了一个0槽和信号相关的代码,代码编译成功,但是槽函数始终接收不到信号, 先看main.cpp文件: 就是定义一个线程 int main(int argc, char *argv[]) { QApplication a(argc, argv); MainWindow w; w.show(); /*定义一个线程,并且启动一个线程*/ MyThread receive_data; receive_data.start(); return a.exec(); } 然后在mainwind

js html-在线等,急(大神帮帮忙):js动态嵌入html代码,代码中调用函数,当传参为字符串时,函数没有响应

问题描述 在线等,急(大神帮帮忙):js动态嵌入html代码,代码中调用函数,当传参为字符串时,函数没有响应 <!DOCTYPE html> <br> function insert()<br> {<br> var a="jioho";<br> var str="<table><tr><button type='button' onclick='test("+ a+"

svn-SVN上传代码是代码失败,怎么解决

问题描述 SVN上传代码是代码失败,怎么解决 账号的权限没有问题,在其他电脑上已验证,但是commit时总是报出如下错误: Description : You are not authorized to access the files in the repository. Suggestion : You might be required to provide a user name and password when prompted before being allowed to acc

大神,C++代码递归代码求详细注释,特别是if中的看不懂,谢谢了

问题描述 大神,C++代码递归代码求详细注释,特别是if中的看不懂,谢谢了 void foo(int x, int y) { if (x > 1000) return; if (x == y && x == 1) { printf("%d %d ", 1, 1); foo(x + y, x); return; } else { printf("%d ", x); foo(x + y, x); } } 解决方案 void foo(int x, i

eclipse源代码-两段代码,代码2无法调用代码1

问题描述 两段代码,代码2无法调用代码1 代码1: public ArrayList queryBalance(String income) { ArrayList al=new ArrayList(); DBUtil db=new DBUtil(); try { java.sql.Connection con=db.getConnection(); String sql="select * from balance where income=?"; java.sql.Prepared

图片-不知道这个红颜色代码到底代码什么意思 ,求解啊

问题描述 不知道这个红颜色代码到底代码什么意思 ,求解啊 解决方案 activex定义一个事件回调

html5-急求教!请JS或H5高手帮忙看个代码,代码中哪段是控制(图片)最大播放数量的?

问题描述 急求教!请JS或H5高手帮忙看个代码,代码中哪段是控制(图片)最大播放数量的? 我是新手,看不太明白,求教... 目前的代码是有10张图片顺序播放,但是我希望只播放3张,也就是最大播放数量控制在3以内. 非常感谢!!! (function(){ var now = { row:1, col:1 }, last = { row:0, col:0}; const towards = { up:1, right:2, down:3, left:4}; var isAnimating = fa

tinyMCE插件开发之插入html,php,sql,js代码 并代码高亮显示_网页播放器

下面就是我开发的过程. 首先,我的 tinyMCE版本是 Version: 3.2.7 (2009-09-22) .下载地址 http://www.jb51.net/codes/17198.htmltinyMCE插入代码,需要调用 tinyMCE的 tinyMCE.execCommand('mceInsertContent',false,value); 方法.其中参数无需改变,value 就是你要插入的内容, 比如我写了一个函数, 复制代码 代码如下: function InsertHTML(v

jQuery实现原理的模拟代码 -6 代码下载_jquery

演示代码: 复制代码 代码如下: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title><