I need a code to get this strings from inside a href tag
Example of weburl:
/video/funny-videos-with-dogs-21608674/
The strings what i need is:
Url Title = funny-videos-with-dogs
Url ID = 21608674
How i can get this 2 strings from the url via preg_match?
Update:
What i try so far is:
preg_match('/\/video\/(.*?)-/is', $vUrl, $vUrl_Title);
but is show me just "funny" ... i need something to can show "funny-videos-with-dogs"
This should be an easy one:
<?php
if (preg_match("#/video/([a-z\-]+)-([0-9]+)/#", "/video/funny-videos-with-dogs-21608674/", $matches)) {
print_r($matches);
$urlTitle = $matches[1];
$urlID = $matches[2];
}
else {
print_r("Not found!");
}
And this yells
Array
(
[0] => /video/funny-videos-with-dogs-21608674/
[1] => funny-videos-with-dogs
[2] => 21608674
)
Taking into account that non other chars should be matched. I'm pretty sure you can simplify the regexp, I don't have a deep regexp knowledge but this should work