I've got a URL, say, $url='https://www.myurl.com/monkey-48-chicken-broccoli-ham.html'. I want to take the path and split the end into two variables: one containing the number (48), and one containing everything after the number (chicken-broccoli-ham).
While I can divide the returned array from my code below into separate words, the problem is, I don't know how many words will be after the number.
So my question is, how do I split the path into "number" and "everything after number" to store those as variables? Here's what I have so far:
$url='https://www.myurl.com/monkey-48-chicken-broccoli-ham.html';
$parsedUrl = parse_url($url);
$path = parse_url($url, PHP_URL_PATH);
$parts = explode('/', $path);
$tag = end($parts);
$tag1 = str_replace("-", " ", $tag); //replace - with spaces
$tag2 = str_replace(".html", "", $tag1);//delete the ".html" off the end
$tag3 = str_replace("monkey", "", $tag2); //delete the "monkey" word.
here's where I need help:
$number = ???;
$wordstring = ???;