3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $address = '131st Avenue 131'; $matchArr = array(); preg_match_all('/(\d+)/', $address, $matchArr); var_dump($matchArr); $number = array_pop(array_pop($matchArr)); $split = explode($number, $address); $lastPart = $number . array_pop($split); $firstPart = implode($number, $split); print 'First part: ' . $firstPart . "\n"; print 'Last part: ' . $lastPart . "\n";
Output for 7.0.0 - 7.1.0
array(2) { [0]=> array(2) { [0]=> string(3) "131" [1]=> string(3) "131" } [1]=> array(2) { [0]=> string(3) "131" [1]=> string(3) "131" } } Notice: Only variables should be passed by reference in /in/VRIC0 on line 7 First part: 131st Avenue Last part: 131
Output for 5.1.0 - 5.6.28
array(2) { [0]=> array(2) { [0]=> string(3) "131" [1]=> string(3) "131" } [1]=> array(2) { [0]=> string(3) "131" [1]=> string(3) "131" } } Strict Standards: Only variables should be passed by reference in /in/VRIC0 on line 7 First part: 131st Avenue Last part: 131
Output for 5.0.5
array(2) { [0]=> array(2) { [0]=> string(3) "131" [1]=> string(3) "131" } [1]=> array(2) { [0]=> string(3) "131" [1]=> string(3) "131" } } Fatal error: Only variables can be passed by reference in /in/VRIC0 on line 7
Process exited with code 255.
Output for 4.3.0 - 5.0.4
array(2) { [0]=> array(2) { [0]=> string(3) "131" [1]=> string(3) "131" } [1]=> array(2) { [0]=> string(3) "131" [1]=> string(3) "131" } } First part: 131st Avenue Last part: 131