3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $string = "00 a 51 - a9"; $numbers = ""; $chars = ""; preg_match_all("/(\d*)(\D*)/", $string, $matches); print_r($matches); foreach($matches as $match) { $numbers .= is_int($match) ? $match : ''; $chars .= !is_int($match) ? $match : ''; } var_dump($numbers); echo " "; var_dump($chars);
Output for 5.4.0 - 7.2.0
Array ( [0] => Array ( [0] => 00 a [1] => 51 - a [2] => 9 [3] => ) [1] => Array ( [0] => 00 [1] => 51 [2] => 9 [3] => ) [2] => Array ( [0] => a [1] => - a [2] => [3] => ) ) Notice: Array to string conversion in /in/Wic4B on line 11 Notice: Array to string conversion in /in/Wic4B on line 11 Notice: Array to string conversion in /in/Wic4B on line 11 string(0) "" string(15) "ArrayArrayArray"
Output for 4.3.0 - 5.3.29
Array ( [0] => Array ( [0] => 00 a [1] => 51 - a [2] => 9 [3] => ) [1] => Array ( [0] => 00 [1] => 51 [2] => 9 [3] => ) [2] => Array ( [0] => a [1] => - a [2] => [3] => ) ) string(0) "" string(15) "ArrayArrayArray"