I'm trying to generate a range of ips using php (CLI)
But i want to remove " [value] => "
And show only the generated range of ips
The code i am using :
function ip_range($start, $end) {
$start = ip2long($start);
$end = ip2long($end);
return array_map('long2ip', range($start, $end));
}
echo "start of ip range :";
$range_one= trim(fgets(STDIN,1024));
echo "End of ip range";
$range_two= trim(fgets(STDIN,1024));
$icodz =ip_range($range_one, $range_two);
print_r($icodz);
Output of this code is :
[0] => 192.168.1.0
[1] => 192.168.1.1
[2] => 192.168.1.2
[3] => 192.168.1.3
[4] => 192.168.1.4
[5] => 192.168.1.5
[6] => 192.168.1.6
[7] => 192.168.1.7
[8] => 192.168.1.8
[9] => 192.168.1.9
[10] => 192.168.1.10
[11] => 192.168.1.11
[12] => 192.168.1.12
The output I want is :
192.168.1.0
192.168.1.1
192.168.1.2
192.168.1.3
192.168.1.4
192.168.1.5
192.168.1.6
192.168.1.7
192.168.1.8
192.168.1.9
192.168.1.10
192.168.1.11
192.168.1.12
Any solution?
\n", $icodz);` will add br and new line between each value in the array and return it as string. – Andreas Jan 04 '18 at 17:33