I'm sure I have asked this before, as I know I have done it - but I cannot recall where I did this.
So if the URL is:
http://www.site.com/product/445/xl/335/ ... /red-shirt
I was to know if "product" appears after that first main slash.
And then I want to query the string after the sixth slash.
If I can find the first slash and put that word into a query, or find the sixth and put that digit into a variable, I am sorted.
As I say, I've done this but no idea where. Either Explode or Pregmatch, but not sure how I count the slashes.
How do you query the data after the 4th slash in a URL?
Moderator: General Moderators
-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
How do you query the data after the 4th slash in a URL?
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.
Re: How do you query the data after the 4th slash in a URL?
Explode is probably the easier of those two options. Which index you use from the resulting array depends on whether or not you're passing in the complete URL (due to the ://). Explode and print_r the result and you'll see which key you want.
-
simonmlewis
- DevNet Master
- Posts: 4435
- Joined: Wed Oct 08, 2008 3:39 pm
- Location: United Kingdom
- Contact:
Re: How do you query the data after the 4th slash in a URL?
Cool, yeah I sussed it. Any more news on the other thread about using the javascript twice "focus"?
viewtopic.php?f=13&t=140273
Tho you wasn't the last contributor.
At the moment we are running the mobile part with just one image, as we cannot see how to do it.
viewtopic.php?f=13&t=140273
Tho you wasn't the last contributor.
At the moment we are running the mobile part with just one image, as we cannot see how to do it.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
All the best from the United Kingdom.