3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $string = "00 a 51 - a9"; $numbers = ""; $chars = ""; preg_match("/(\d*)(\D*)/", $string, $matches); //print_r($matches); foreach($matches[1] as $match) { $numbers .= is_int($match) ? $match : ''; } foreach($matches[2] as $match) { $chars .= !is_int($match) ? $match : ''; } var_dump($numbers); echo " "; var_dump($chars);
Output for 4.3.0 - 4.3.10, 4.4.0 - 5.6.28, 7.0.0 - 7.1.0
Warning: Invalid argument supplied for foreach() in /in/cfYcO on line 9 Warning: Invalid argument supplied for foreach() in /in/cfYcO on line 13 string(0) "" string(0) ""
Output for hhvm-3.10.0 - 3.12.0
Warning: Invalid argument supplied for foreach() in /in/cfYcO on line 11 Warning: Invalid argument supplied for foreach() in /in/cfYcO on line 15 string(0) "" string(0) ""
Output for 4.3.11
string(0) "" string(0) ""