3v4l.org

run code in 300+ PHP versions simultaneously
<?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";

preferences:
37.42 ms | 402 KiB | 5 Q