3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $arrAgent = array( 'sony', 'symbian', 'nokia', 'samsung', 'mobile', 'windows ce', 'blackberry', 'ericsson', 'danger', 'palm', 'series60', 'palmsource', 'pocketpc', 'smartphone', 'vodafone', 'iphone', 'android', 'ipad' ); $agent = 'mozilla/5.0 (ipad; u; cpu os 4_3_2 like mac os x; en-us) applewebkit/533.17.9 (khtml, like gecko) version/5.0.2 mobile/8h7 safari/6533.18.5'; $pattern = '/((' . implode(')|(', $arrAgent) . '))/'; $found = preg_match($pattern, $agent, $matches); if (!$found) { print 'not a mobile device'; exit; } print 'device: ' . $matches[0];
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
device: ipad