I have an array $cfg=Array('5.3', '5.4') which contains major Php versions. I want to determine major from version. For example if input is 5.4.10-1ubuntu3 the response should be 5.4. My code is this:
foreach ($cfg as $key => $phpMajor) {
if (version_compare($phpVersion, $phpMajor, '>=') and version_compare($phpVersion, $cfg[$key+1], '<')) {
var_dump($phpMajor);
}
}
But this is not cover my all possibilities. Can you help me please?
PHP_VERSION,PHP_MAJOR_VERSION,PHP_MINOR_VERSIONconstants?