Print_r ($dataIp); foreach ($dataIp as $key = + $value) { $data [' IP '] = $value; $data [' iplong '] = Bindec (Decbin (Ip2long ($value))); Print_r ($data); }
The results are printed as follows:
Array
(
[0] = 208.104.70.215
[1] = 74.101.176.171
[2] = 73.17.35.30
[3] = 70.198.197.3
[4] = 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] = 46.44.179.76
[Iplong] = 774681420
)
Only the last one succeeds, the others fail, what is the reason?
Reply to discussion (solution)
Ip2long can't convert an array?
No problem
Array ( [IP] = 208.104.70.215 [Iplong] = 3496494807) Array ( [IP] = 74.101.176.171 [Iplong] = = 1248178347) array ( [IP] = 73.17.35.30 [Iplong] = 1225859870) Array ( [IP] + 70.198.197.3 [Iplong] = 1187431683) Array ( [IP] = 46.44.179.76 [Iplong] = 774681420)
But I don't know what you're doing.
Moderator adults have not changed the code, I have tried in the local countless times have only read the last one. I don't know what the reason is.
$value) {$data [' IP '] = $value; $data [' iplong '] = Bindec (Decbin (Ip2long ($value))); Print_r ($data); }
Output
Array ( [IP] = 208.104.70.215 [Iplong] = 3496494807) Array ( [IP] = 74.101.176.171 [ Iplong] = 1248178347) Array ( [IP] = 73.17.35.30 [Iplong] + 1225859870) Array ( [IP] = 70.198.197.3 [Iplong] = 1187431683) Array ( [IP] = 46.44.179.76 [Iplong] + 774681420)
is normal.
If you put Print_r ($data); Put it outside the loop, it's the last one.
???, normal.
My full code is like this.
$dataIp = explode ("\ n", $_post[' IP '), if (Empty ($dataIp)) {$this->error (' not filled ip! ');} $dataIp = Array (' 208.104.70.215 ', ' 74.101.176.171 ', ' 73.17.35.30 ', ' 70.198.197.3 ', ' 46.44.179.76 ');p Rint_r ($dataIp ), foreach ($dataIp as $key = + $value) { $data [' IP '] = $value; $data [' iplong '] = Bindec (Decbin (Ip2long ($value))); Print_r ($data); }
If the IP in the fifth row of numbers is entered after the form is submitted, the printed array is the same regardless of whether the fifth line is commented.
But the results of the cycle are different, the results are shown. I really don't know how this problem came up, tangled up a good while.
Thank you for the upstairs several to find the problem, is the form inside the front and rear space resulting in not getting the value.