3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $string = "00 a 51 - a9b"; $numbers = ""; $chars = ""; preg_match_all("/(\d*)(\D*)/", $string, $matches); //print_r($matches); foreach($matches[1] as $match) { $numbers .= is_int($match) ? $match : ''; echo $match; } foreach($matches[2] as $match) { $chars .= !is_int($match) ? $match : ''; } var_dump($numbers); echo " "; var_dump($chars);
Output for 4.3.0 - 7.1.0
00519string(0) "" string(8) " a - ab"