I have strings like this:
Lesson 001: Complete
I want to only get the number part, in this case 001
.
I tried this:
$str = the_title();
preg_match_all('!\d+!', $str, $matches);
$number = implode(' ', $matches[0]);
echo $number;
But echo $number
outputs the entire string once again: Lesson 001: Complete
How to do this correctly?