3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $ua = 'Mozilla/5.0 (Linux; Android 4.0; Galaxy Nexus Build/IMM76B) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.133 Mobile Safari/535.19'; $pattern = "/Android (\d).(\d)(?:.(\d))?/"; preg_match($pattern, $ua, $matches); $androidversion = array(0,0,0); if (sizeof($matches) == 0 ) { error_log("No Android version match");}if (sizeof($matches) == 1) { error_log("No major version");} if (sizeof($matches) >= 2) { $androidversion[0] = $matches[1];}if (sizeof($matches) >=3) { $androidversion[1] = $matches[2];}if (sizeof($matches) >= 4) { $androidversion[2] = $matches[3];}function isAndroidVersion($androidversiontocheck, $major, $mid, $minor){ if ($androidversiontocheck[0] == $major and $androidversiontocheck[1] == $mid and $androidversiontocheck[2] == $minor){ return True; } return False;}function isEqualorGreaterAndroidVersion($androidversiontocheck, $major, $mid, $minor){ if ($androidversiontocheck[0] < $major){ return False; }else if ($androidversiontocheck[1] < $mid){ return False; }else if ($androidversiontocheck[2] < $minor){ return False; }else{ return True; }}print (isEqualorGreaterAndroidVersion($androidversion, 4,0,1));print_r($androidversion);
based on 2UaD2
Output for 4.3.0 - 5.6.28, hhvm-3.12.0, 7.0.0 - 7.1.0
Array ( [0] => 4 [1] => 0 [2] => 0 )
Output for hhvm-3.10.0

Process exited with code 153.