3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $ip = 'a.b.c.d'; $octets = explode('.', $ip); var_dump($octets); foreach($octets as $key => $octet) { (255 - (int) $octet) < 0 ? $valid = false : $valid = true; if ($valid) echo 'valid'; else echo 'invalid'; echo PHP_EOL; } var_dump($octets);
based on WH0jE
Output for 4.3.10 - 4.4.9, 5.0.2 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
array(4) { [0]=> string(1) "a" [1]=> string(1) "b" [2]=> string(1) "c" [3]=> string(1) "d" } valid valid valid valid array(4) { [0]=> string(1) "a" [1]=> string(1) "b" [2]=> string(1) "c" [3]=> string(1) "d" }
Output for 4.3.0 - 4.3.9, 5.0.0 - 5.0.1
array(4) { [0]=> string(1) "a" [1]=> string(1) "b" [2]=> string(1) "c" [3]=> string(1) "d" } valid Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/nhvWL on line 18 PHP_EOLvalid Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/nhvWL on line 18 PHP_EOLvalid Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/nhvWL on line 18 PHP_EOLvalid Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/nhvWL on line 18 PHP_EOLarray(4) { [0]=> string(1) "a" [1]=> string(1) "b" [2]=> string(1) "c" [3]=> string(1) "d" }