function to detect mobile brand

Started on the old forum in October 2010 · view the original in the archive · old links redirect here

5 replies · 1,440 views · started 16 years ago · 2 min read

5 participants
GumSlone Administrator Principal · 1,690 posts #1

Here is a function which detects mobile brand, other wapmasters are welcome to improve this function and post here their works.

function brand_detect($user_agent)
{
 $brands = array(
 			array(
 				'id' => '100',
 				'brand' => 'Nokia',
 				'check' => array('nokia')
 			),
 			array(
 				'id' => '200',
 				'brand' => 'SonyEricsson',
 				'check' => array('sonyericsson')
 			),
 			array(
 				'id' => '300',
 				'brand' => 'Samsung',
 				'check' => array('samsung','sec-','sam-','sgh-')
 			),
 			array(
 				'id' => '400',
 				'brand' => 'LG',
 				'check' => array('lg/','lg-')
 			),
 			array(
 				'id' => '500',
 				'brand' => 'Motorola',
 				'check' => array('mot-','moto')
 			),
 			array(
 				'id' => '600',
 				'brand' => 'RIM BlackBerry',
 				'check' => array('blackberry')
 			),
 			array(
 				'id' => '700',
 				'brand' => 'HTC',
 				'check' => array('htc')
 			),
 			array(
 				'id' => '800',
 				'brand' => 'Apple',
 				'check' => array('ipod','iphone','ipad')
 			),
 			array(
 				'id' => '900',
 				'brand' => 'Sagem',
 				'check' => array('sagem')
 			),
 			array(
 				'id' => '1010',
 				'brand' => 'Bird',
 				'check' => array('bird')
 			),
 			array(
 				'id' => '1020',
 				'brand' => 'Zen',
 				'check' => array('z77')
 			),
 			array(
 				'id' => '1030',
 				'brand' => 'Haier',
 				'check' => array('htil')
 			),
 			array(
 				'id' => '1040',
 				'brand' => 'Micromax',
 				'check' => array('micromax')
 			),
 			array(
 				'id' => '1050',
 				'brand' => 'Spice',
 				'check' => array('spice')
 			),
 			array(
 				'id' => '1060',
 				'brand' => 'ZTE',
 				'check' => array('zte-')
 			),
 			array(
 				'id' => '1070',
 				'brand' => 'Huawei',
 				'check' => array('huawei')
 			),
 			array(
 				'id' => '1080',
 				'brand' => 'Fly',
 				'check' => array('fly-')
 			),
 			array(
 				'id' => '1090',
 				'brand' => 'Nexian',
 				'check' => array('nexian')
 			),
 			array(
 				'id' => '9090',
 				'brand' => 'RT',
 				'check' => array('rt')
 			)
 			/*array(
 				'id' => '800',
 				'brand' => 'Apple Ipod Touch',
 				'check' => array('ipod')
 			),
 			array(
 				'id' => '810',
 				'brand' => 'Apple Iphone',
 				'check' => array('iphone')
 			),
 			array(
 				'id' => '820',
 				'brand' => 'Apple Ipad',
 				'check' => array('ipad')
 			)*/

 );
	foreach($brands as $brand)
	{
		foreach($brand['check'] as $check)
		{
			if(stristr($user_agent,$check))
			{
				$found = true;
				break;
			}
		}
		if($found) break;
	}
	return $brand;
}

usage:

$ua = 'Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1A543a Safari/419.3';

print_r(brand_detect($ua));

output:

Array ( [id] => 800 [brand] => Apple [check] => Array ( [0] => ipod [1] => iphone [2] => ipad ) )

Advertise your mobile site for FREE with AdTwirl

External image (may be gone)

subzero Super moderator Fellow · 3,954 posts #2

LTE bubble touch lol not in the list but i will add it

Visit: Chat4u.mobi - The New Lay Of being a site of your dreams! Visit: WapMasterz Coming Back Soon!


SCRIPTS FOR SALE BY SUBZERO Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders. FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others... _______…

centi Developer · 159 posts #3

i think u post exactly something like this b4

😳 .................................... http://photomag.lk/ .................................... 🤨

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close