3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function reverse($string) { $substr1 = ""; $substr2 = ""; $strLength = strlen($string)-1; for ($i = 0; $i < ($strLength / 2); $i++) { $substr1[] += $string[$strLength-$i]; $substr2[] += $string[$i]; } //var_dump($substr1); //var_dump($substr2); return $string = $substr1 + $substr2; } var_dump(reverse('12345'));
based on rf0O6
Output for 7.1.0
Fatal error: Uncaught Error: [] operator not supported for strings in /in/geGtr:7 Stack trace: #0 /in/geGtr(15): reverse('12345') #1 {main} thrown in /in/geGtr on line 7
Process exited with code 255.
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.0.14
array(2) { [0]=> int(5) [1]=> int(4) }