3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $androidApp = 'ZooskAndroid'; $iphoneApp = 'ZooskiPhone'; $ipadApp = 'ZooskiPad'; $ua = 'ZooskAndroid/167 (Linux; U; Android 4.2.2; en-US; KFSOWI; Build/JDQ39)'; $regExp = '/^(?:(?:' . $androidApp . ')|(?:' . $iphoneApp . ')|(?:' . $ipadApp . '))\/([0-9.]{1,6}),/'; preg_match_all($regExp, $ua, $matches); if (is_array($matches) && count($matches) === 2) { $version = $matches[1]; } if (empty($version)) { // ZooskAndroid/133 (Linux; U; Android 4.4.2; en-US; HTC One; Build/KOT49H.H1) $regExp = '/^(?:(?:' . $androidApp . '))\/([0-9.]{1,6}) \(/'; preg_match_all($regExp, $ua, $matches); $version = $matches[1]; } if (is_array($version) && count($version) === 1) { $version = is_array(current($version)) ? null : current($version); } else { $version = null; } echo $version;
based on 4hfXD
Output for 4.3.0 - 7.1.0
167