Fairly rubbish with PHP, this is a continuation on from my last question.
I have a list of user agents inside an array, and I want an output to be true if the user agent matches one listed inside the array.
This is what I have for a single user agent:
<?php
function mediaType(){
$browser = strpos($_SERVER['HTTP_USER_AGENT'],"iPhone");
$var = 0;
if ($browser !== false) { $var = 1; }
return $var;
}
?>
I want something like this:
<?php
function mediaType(){
$userAgents = array("iPhone", "Chrome");
$browser = $_SERVER['HTTP_USER_AGENT'];
$var = 0;
if (in_array($browser, $userAgents)) {
$var = 1;
}
return $var;
}
?>
I guess a while loop would be a good option, but I am clueless.