It's not bad, but I think it's a very basic way to for checking the UA (user-agent). If you're lucky, it will be correct in 90% of cases, not more. Because UA sometimes get extremely complex and confusing.
If you want something more advanced, I would suggest you to use this php library...