Skip to content

Instantly share code, notes, and snippets.

@SeanJA
Forked from gavinblair/index.php
Created June 10, 2010 16:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SeanJA/433283 to your computer and use it in GitHub Desktop.
Save SeanJA/433283 to your computer and use it in GitHub Desktop.
mobile browser detection
<?php
$mobiles = array(
'iphone','ipod','android','blackberry',//and so on
);
$agent = strtolower($_SERVER['HTTP_USER_AGENT']);
if($match = preg_match('/('.implode('|',$mobiles).')/', $agent)){
echo 'mobile';
//include mobile stuff here
} else {
echo 'not mobile';
//do normal stuffs
}
@SeanJA
Copy link
Author

SeanJA commented Jun 10, 2010

Right... erm... I meant that...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment