I am designing a wordpress website for mobile application. For the visitor, I want to display text, images based on operating system like the below page -
https://www.sapphireone.com/accounting-software/accounts/
In this page, in 'Accounts Structure section' there is a image that changes based on operating system , i.e. mac and windows.
I want to do similar thing for android and iPhone. I am using the following code, but it is not working.
//code for function.php
function find_andoird() {
$ua = $_SERVER[‘HTTPS_USER_AGENT’];
/* ==== Detect the OS ==== */
// Android
$android = strpos($ua, 'Android') ? true : false;
// iPhone
$iphone = strpos($ua, 'iPhone') ? true : false;
return $android;
}
//Code for template file
if(find_andoird() == true) {
<p><strong>Android View</strong></p>
<p>
<img src=“accounting-android.png” style="float:left;width:400px;height:600px;">
The android view is displayed here.
</p>
}
else {
<p><strong>iPhone View</strong></p>
<p>
<img src=“accounting-iphone.png” style="float:left;width:400px;height:600px;">
The iphone view is displayed here.
</p>
}
}
Can I get some help please. Thanks