Page 1 of 1

How do you query the data after the 4th slash in a URL?

Posted: Thu Sep 25, 2014 4:21 am
by simonmlewis
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.

Re: How do you query the data after the 4th slash in a URL?

Posted: Thu Sep 25, 2014 7:58 am
by Celauran
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.

Re: How do you query the data after the 4th slash in a URL?

Posted: Thu Sep 25, 2014 8:11 am
by simonmlewis
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.