Hey guys, im not new to php or can't do stuff like that with php, no i can, but the problem is that im not that powerful with regex , so what i need is someone of you guys would give me a working regex that would do the following: if i have a link like this "page-slug/the/rest/of/the/link" i want to strip out the word "page-slug" ONLY , i don't want any of the other words ps: this is not a constant url, this may change to any other link at all, all i need is just to get the very first slug and then stop when it met the "/" symbol Any other question just ask guys ,, Thanks a lot
Might be an easier way, but this will work. $url = "http://domain.com/page-slug/the/rest/of/the/link"; $url = str_replace("http://","",$url); $parts = explode("/", $url); echo $parts[1]; // = page-slug // $parts[0]; = domain.com // $parts[2]; = the PHP:
Wow, Thanks so mush. i didn't think of it that way, but this is really helpful you just saved my life Thanks a lot