3v4l.org

run code in 300+ PHP versions simultaneously
<?php function ipv4Breakout ($ip_address, $ip_nmask) { $hosts = array(); //convert ip addresses to long form $ip_address_long = ip2long($ip_address); $ip_nmask_long = ip2long($ip_nmask); //caculate network address $ip_net = $ip_address_long & $ip_nmask_long; //caculate first usable address $ip_host_first = ((~$ip_nmask_long) & $ip_address_long); $ip_first = ($ip_address_long ^ $ip_host_first) + 1; //caculate last usable address $ip_broadcast_invert = ~$ip_nmask_long; $ip_last = ($ip_address_long | $ip_broadcast_invert) - 1; //caculate broadcast address $ip_broadcast = $ip_address_long | $ip_broadcast_invert; foreach (range($ip_first, $ip_last) as $ip) { array_push($hosts, $ip); } $block_info = array(array("network" => "$ip_net"), array("first_host" => "$ip_first"), array("last_host" => "$ip_last"), array("broadcast" => "$ip_broadcast"), $hosts); return $block_info; } print_r(ipv4Breakout ('96.4.3.0', '255.255.255.0'));
Output for 8.3.0 - 8.3.6
Fatal error: Uncaught ValueError: The supplied range exceeds the maximum array size: start=-2684091394 end=1610875649 step=1 in /in/9LoFN:23 Stack trace: #0 /in/9LoFN(23): range(1610875649, -2684091394) #1 /in/9LoFN(36): ipv4Breakout('96.4.3.0', '255.255.255.0') #2 {main} thrown in /in/9LoFN on line 23
Process exited with code 255.
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18
Fatal error: Uncaught ValueError: The supplied range exceeds the maximum array size: start=-2684091394 end=1610875649 in /in/9LoFN:23 Stack trace: #0 /in/9LoFN(23): range(1610875649, -2684091394) #1 /in/9LoFN(36): ipv4Breakout('96.4.3.0', '255.255.255.0') #2 {main} thrown in /in/9LoFN on line 23
Process exited with code 255.
Output for 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
Warning: range(): The supplied range exceeds the maximum array size: start=-2684091394 end=1610875649 in /in/9LoFN on line 23 Warning: Invalid argument supplied for foreach() in /in/9LoFN on line 23 Array ( [0] => Array ( [network] => 1610875648 ) [1] => Array ( [first_host] => 1610875649 ) [2] => Array ( [last_host] => -2684091394 ) [3] => Array ( [broadcast] => -2684091393 ) [4] => Array ( ) )
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.40
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 32 bytes) in /in/9LoFN on line 23
Process exited with code 255.

preferences:
273.93 ms | 402 KiB | 330 Q