Skip to content
Advertisement

Check if array value contains browser country code

I’m trying to show a link to a German version of my landing page if German is one of the browser languages, but the issue I am having is that the array is returning all languages in one value. How can I check to see if the value contains certain letters? Here is the code I am using and the return I see:

JavaScript

I am getting the following returned:

JavaScript

So the issue I am having is the value is not specifically “de”, but does contain “de”, so the link is not displaying. How can I check that “de” is withing the returned value. Thank you

Advertisement

Answer

you could use strpos, as

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement