I'm trying to compare some IP addresses that are stored as strings. I read about ip2long()
to convert the string to an integer so I'm playing around with it to see if it would do what I want. So, initially, I'm just trying to see what the converted IP looks like. I wrote the following code to look at that but nothing is being converted. I don't see what I'm doing wrong. Here is the code:
<?php
foreach($form->data[vicondb] as $video_net_key)
{
if ($video_net_key['ipaddress'] != null)
{
echo "The IP address is " . $video_net_key['ipaddress'];
$iplong = ip2long($video_net_key['ipaddress']);
echo " --- The ip long conversion is " . $iplong . "<br>";
}
} // End foreach($form->data[vicondb] as $video_net_key)
echo "End of both foreach statements<br>";
?>
Here is a sample of the result:
The IP address is 172.26.0.10 --- The ip long conversion is
The IP address is 172.26.0.31 --- The ip long conversion is
The IP address is 172.26.0.32 --- The ip long conversion is
The IP address is 172.26.0.33 --- The ip long conversion is
Here is a sample of the var_dump()
for IP and converted to integer:
string(12) "172.26.0.10 "
bool(false)
string(12) "172.26.0.31 "
bool(false)
string(12) "172.26.0.32 "
bool(false)