3v4l.org

run code in 300+ PHP versions simultaneously
<?php function get_numerics ($str) { preg_match('/^mom_(\d+)$/', $str, $matches); if (defined($matches[1])) return $matches[1] . "<br />"; else return "Not found <br />"; } $one = 'mom_5'; $two = 'mom_123'; $three = 'actions'; print_r(get_numerics($one)); print_r(get_numerics($two)); print_r(get_numerics($three));

preferences:
41.41 ms | 402 KiB | 5 Q