This I think is the easiest way to detect what type of device is being used by a visitor to your site - we used it to display the correct Map app icon but it can be modified easily to fit your needs. this is a If then else statement.
<?php
if (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac OS') !== false) {
?>the
strpos searches the HTTP_USER_AGENT to determine what device is being used for the Filter you supply
'Mac OS' in this case.
a typical HTTP_USER_AGENT if echoed to your screen would look like this :
Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.4 (KHTML, like Gecko) Chrome/22.0.1229.94 Safari/537.4by using the
strpos it can search the entire HTTP_USER_AGENT string for what ever filter word you want.
Our examples below looked for Apple, Android & Windows to display the correct Map App icon and link
Macintosh Filter
<?php
if (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac OS') !== false) {
?>
------- display what ever you want based on the filter match here ------------
<a href="maps://?q=<?php echo $row_rsclass_events['event_address']; ?> <?php echo $row_rsclass_events['event_city']; ?>, <?php echo $row_rsclass_events['event_zip']; ?><img src="../../assets/2016/ios-maps-icon.jpg" width="72" height="72" hspace="0" vspace="0" align="middle" /></a>
------- end display area --------------------------------------
<?php
}
?>
Android Filter
<?php
if (strpos($_SERVER['HTTP_USER_AGENT'], 'Andriod') !== false) {
?>
<a href="geo://0,0?q=<?php echo $row_rsclass_events['event_address']; ?> <?php echo $row_rsclass_events['event_city']; ?>, <?php echo $row_rsclass_events['event_st']; ?> <?php echo $row_rsclass_events['event_zip']; ?> <img src="../assets/2016/Maps-Android-R.png" width="72" height="72" hspace="5" vspace="5" /></a>
<?php
}
?>
Windows Filter
<?php
if (strpos($_SERVER['HTTP_USER_AGENT'], 'Windows') !== false) {
?>
<a href="http://maps.google.com/?q=<?php echo $row_rsclass_events['event_address']; ?> <?php echo $row_rsclass_events['event_city']; ?>, <?php echo $row_rsclass_events['event_st']; ?> <?php echo $row_rsclass_events['event_zip']; ?> " target="_blank"><img src="glovebox/code/images/map0-with-pin.png" width="72" height="72" hspace="5" vspace="5" /></a>
<?php
}
?>