Is it possible to check if the url contains certain values, for instance if the URL "www.example.com/dummy1/dummy2/dummy3/en/dummy4/tim/" has an "en" or not.
Thanks
Is it possible to check if the url contains certain values, for instance if the URL "www.example.com/dummy1/dummy2/dummy3/en/dummy4/tim/" has an "en" or not.
Thanks
You can use the strpos function which is used to find the occurrence of one string inside other:
LIKE THIS
The answers above may be what you're looking for, but in addition to searching for your value, here is how to actually retrieve the URL...
I'm assuming you want to know if a user is on a page that contains 'en' in which case you really don't need to check against the domain name, so you might do something like...
you should note using strpos will also return true(actually it will return the match's start position in the string) if you have the character string en anywhere in the url, for example the word then would return true, so if you're looking for /en/ you can either use the in_array method described by other users to check, or simply check for the string '/en/' using this method