>The problem I'm having is that the data contained in $HTTP_USER_AGENT
>string variable. Thus, there is no way I can see to split it up into
>meaningful chunks that can be used in an "if" test. Because it's a
>can't use implode(), which is one thing I did try.
>Anyone know of a way to do this, short of using regular expressions?
This is a good question as there doesn't seem to be any standard for the
format of the string returned by $HTTP_USER_AGENT. It's a sad statement
of the browser industry in my opinion. Anyway, If you know what the
choices are, you might try just using string search functions such as
strstr() which returns either a substring starting with your match or
FALSE. You wouldn't really care about the substring, just that you
don't get FALSE.
So one solution might be something like:
if (strstr($HTTP_USER_AGENT, "MSIE 5.0"))
// handle IE version 5.0 browsers
if (strstr($HTTP_USER_AGENT, "MSIE 4.0"))
// handle IE vedrsion 4.0 browsers
Admittedly, this is kind of kludgy and I'm anxious to see some more
elegant solution by a more experienced php developer.
P.s. Wouldn't it be cool if all browser companies just provided a
bitmap that you could XOR with predefined bit patterns, each bit pattern
assigned to an industry standard code for a particular browser or
Then you could control which features you utilized for each site
dynamically. Oh well.