3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $ip = '192.168.0.1'; $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 SaYhc
Output for 4.3.10 - 4.4.9, 5.0.2 - 7.1.0
array(4) { [0]=> string(3) "192" [1]=> string(3) "168" [2]=> string(1) "0" [3]=> string(1) "1" } valid valid valid valid array(4) { [0]=> string(3) "192" [1]=> string(3) "168" [2]=> string(1) "0" [3]=> string(1) "1" }
Output for 4.3.0 - 4.3.9, 5.0.0 - 5.0.1
array(4) { [0]=> string(3) "192" [1]=> string(3) "168" [2]=> string(1) "0" [3]=> string(1) "1" } valid Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/WH0jE on line 18 PHP_EOLvalid Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/WH0jE on line 18 PHP_EOLvalid Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/WH0jE on line 18 PHP_EOLvalid Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/WH0jE on line 18 PHP_EOLarray(4) { [0]=> string(3) "192" [1]=> string(3) "168" [2]=> string(1) "0" [3]=> string(1) "1" }