Hello interwebs,
I'm looking for a logical solution for the following task:
I want to match the category part of the url of any possible combinations and limit them to 2 pieces;
for example:
the problem is that I can't check for the .html or any .* extension because not all websites have this kind of url structure;
my current work is this: explode by '/': if count($pieces <= 1) continue; array_pop($pieces) array_slice($pieces, 0, 2); implode('/', $pieces)
the issue here is that on pages such as /cat/subcat I'll have the result 'cat' and, ongoing, for /cat => /
to make sense of my task I'll say that I want to match all possible urls of a website by the most common prefixes and limit the match by a factor of maximum 2 prefix categories (but excluding the page.html or any kind of page that is not a subcat). Simple right?
My question to all of you all, if you'll be so kind as to help me, is: "What suggestions do you have for me regarding this concept?"
I thank the PHP comunity,
Cheers!