Skip to content

Instantly share code, notes, and snippets.

Forked from gavinblair/index.php
Created Jun 10, 2010
What would you like to do?
mobile browser detection
$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
Copy link

gavinblair commented Jun 10, 2010

line 5: strotolower -> strtolower :)

seems to work, and is much nicer to read. thanks!

Copy link

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