getNumberFromEndOfUrl() pulling number from middle of a URL?

3 posts by 2 authors in: Forums > CMS Builder
Last Post: May 24, 2010   (RSS)

Re: [dougdrury] getNumberFromEndOfUrl() pulling number from middle of a URL?

By Dave - May 24, 2010

Hi Doug,

Yea, it actually gets the last number in the url even if it's not at the end of the url. It does that so you can have urls like this: ?article-name-####.html

Try this:
// get last number in url
$lastNumber = 0;
if (preg_match("/(\d+)$/", @$_SERVER['QUERY_STRING'], $matches)) {
$lastNumber = $matches[1];
}

print "Last Number: $lastNumber<br/>\n";


Let me know if that works for you.
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] getNumberFromEndOfUrl() pulling number from middle of a URL?

By dougdrury - May 24, 2010

Dave,
Thanks for the clarification! I will try the preg_match(). Great idea! Thank you!!

Doug