Reputation: 409
I'm trying to display the name of the apple device model on my website
I'm currently using this PHP code to get the device model:
$device = $_SERVER["HTTP_X_MACHINE"];
echo $device;
this code gets the device model but display it as for example if i'm on an iPad 4 Wifi the result is iPad3.4 how can i change the displayed text in a way to replace "iPad3.4" with "iPad 4 WiFi" and "iPad3.5" with "iPad 4 GSM" etc...
Upvotes: 0
Views: 67
Reputation: 26
...If you want, you can do something like this:
$device = $_SERVER["HTTP_X_MACHINE"];
$conversions = array(
'iPad3.4' => 'iPad 4 WiFi',
'iPad3.5' => 'iPad 4 GSM',
);
if (isset($conversions[$device])) echo $conversions[$device];
Without knowing any PHP, this might be a little hard to get working correct, though. Feel free to try it, anyway.
Upvotes: 1
Reputation: 669
Something like that should do the job, assuming you known most of values :
$deviceMapping = array(
'iPad3.4' => 'iPad 4 WiFi',
'iPad3.5' => 'iPad 4 GSM',
);
$device = $_SERVER["HTTP_X_MACHINE"];
if (isset($deviceMapping[$device])) {
echo $deviceMapping[$device];
} else {
echo "Unknown device";
}
Upvotes: 1