3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function str_to_address($context) { $array = explode(" ", $context); $array_reversed = array_reverse($array); $numKey = ""; $zipKey = ""; foreach($array_reversed as $k=>$str) { if($zipKey) { continue; } if(strlen($str)===5 && is_numeric($str)) { $zipKey = $k; } } $array_reversed = array_slice($array_reversed, $zipKey); $array = array_reverse($array_reversed); foreach($array as $k=>$str) { if($numKey) { continue; } if(strlen($str)>1 && strlen($str)<6 && is_numeric($str)) { $numKey = $k; } } $array = array_slice($array, $numKey); $string = implode(' ', $array); return $string; } echo str_to_address("Sally sells seashells at 819 Timber Glen Ln. Ballwin and loves it."); ?>
Output for 7.0.0 - 7.1.0
Warning: array_slice() expects parameter 2 to be integer, string given in /in/DSjLY on line 13 Warning: array_reverse() expects parameter 1 to be array, null given in /in/DSjLY on line 14 Warning: Invalid argument supplied for foreach() in /in/DSjLY on line 15 Warning: array_slice() expects parameter 1 to be array, null given in /in/DSjLY on line 22 Warning: implode(): Invalid arguments passed in /in/DSjLY on line 23
Output for hhvm-3.12.0
Warning: array_slice() expects parameter 2 to be integer, string given in /in/DSjLY on line 13 Warning: array_reverse() expects parameter 1 to be array, null given in /in/DSjLY on line 14 Warning: Invalid argument supplied for foreach() in /in/DSjLY on line 21 Warning: array_slice() expects parameter 2 to be integer, string given in /in/DSjLY on line 22 Warning: Invalid operand type was used: implode() expects a container as one of the arguments in /in/DSjLY on line 23
Output for hhvm-3.10.0

Process exited with code 153.
Output for 5.3.0 - 5.6.28
Warning: array_slice() expects parameter 2 to be long, string given in /in/DSjLY on line 13 Warning: array_reverse() expects parameter 1 to be array, null given in /in/DSjLY on line 14 Warning: Invalid argument supplied for foreach() in /in/DSjLY on line 15 Warning: array_slice() expects parameter 1 to be array, null given in /in/DSjLY on line 22 Warning: implode(): Invalid arguments passed in /in/DSjLY on line 23
Output for 5.2.6 - 5.2.17
Warning: array_slice() expects parameter 2 to be long, string given in /in/DSjLY on line 13 Warning: array_reverse(): The argument should be an array in /in/DSjLY on line 14 Warning: Invalid argument supplied for foreach() in /in/DSjLY on line 15 Warning: array_slice() expects parameter 1 to be array, null given in /in/DSjLY on line 22 Warning: implode(): Invalid arguments passed in /in/DSjLY on line 23
Output for 4.3.0 - 5.2.5
819 Timber Glen Ln. Ballwin and loves it.