View Full Version : Using PHP to extract thread ID from a vbulletin URL ?
jwocky
04-26-2009, 12:24 AM
For example, say I make a variable
$url = 'https://vborg.vbsupport.ru/showthread.php?t=93531';
Now does anyone know a good PHP routing (using preg match possibly?) so strip out only the thread ID from that URL, in this case 93531
Thanks!!
Lynne
04-26-2009, 02:53 AM
Try looking up different functions for string manipulation in the php manual/site. I know I've seen something there to do what you want. http://us3.php.net/strings
Dismounted
04-26-2009, 05:15 AM
Also note that "t" is an alias for "threadid" in vBulletin (i.e. you can use both).
jwocky
04-26-2009, 11:39 AM
Yea I've been trying to form a nice statement to extract that information but its just not working out for me, I bet its something that people have used all the time on here for various modfications so i'm hoping someone can copy/paste their string for everyone to use/
Dismounted
04-26-2009, 11:59 AM
Here's one I created quickly:
// note that strrpos() can only accept more than one char in php5
$pos = strrpos('t=', $url);
$pos = ($pos === false) ? strrpos('threadid=', $url) : $pos + 2;
$pos = ($pos === false) ? false : $pos + 9;
if ($pos !== false)
{
$threadid = substr($url, $pos);
}
vBulletin® v3.8.12 by vBS, Copyright ©2000-2024, vBulletin Solutions Inc.