- preg_match: documentation ( source)
- print_r: documentation ( source)
<?php
function get_numerics ($str) {
preg_match( '/(?<=\bLevel\s)(?:[\w-]+)/is', $str, $matches);
return $matches;
}
$one = 'aasdjhgasd asgdahjsd hjg 4ht ahsjdhkajsdhakjsdh Level 1, 100 XP Unlocked 3 Jul';
$string = "This is a string, keyword next, some more text. keyword next-word. keyword another_word. Okay, keyword do-rae-mi-fa_so_la.";
print_r(get_numerics($one));
print_r(get_numerics($string));