jvit
JVIT PHPThis function will convert the PHP version from a string to an integer.
This function will convert the PHP version from a string to an int.
Shortcut: system.convertVersion
/**
* convert PHP version from string to int
*/
function convertPHPVersionToInt(string $version): int
{
$explodeDash = \explode('-', $version);
if (\count($explodeDash) > 1) {
$version = $explodeDash[0];
}
$explodeVersion = \explode('.', $version);
$countExplodedVersion = \count($explodeVersion);
if ($countExplodedVersion === 2) {
return (int) $explodeVersion[0] * 10000 + (int) $explodeVersion[1] * 100;
}
if ($countExplodedVersion >= 3) {
return (int) $explodeVersion[0] * 10000 + (int) $explodeVersion[1] * 100 + (int) $explodeVersion[2];
}
return (int) $version;
}