public function compareVersions($sourceVer, $compareVer)
    {
        $sourceVer = explode('.', $sourceVer);
        foreach ($sourceVer as $k => $v) {
            $sourceVer[$k] = $this->parseInt($v);
        }

        $compareVer = explode('.', $compareVer);
        foreach ($compareVer as $k => $v) {
            $compareVer[$k] = $this->parseInt($v);
        }

        if (count($sourceVer) != count($compareVer)) {
            if (count($sourceVer) > count($compareVer)) {
                for ($i = count($compareVer); $i < count($sourceVer); $i++) {
                    $compareVer[$i] = 0;
                }
            } else {
                for ($i = count($sourceVer); $i < count($compareVer); $i++) {
                    $sourceVer[$i] = 0;
                }
            }
        }

        foreach ($sourceVer as $i => $srcVerPart) {
            if ($srcVerPart > $compareVer[$i]) {
                return 1;
            } else {
                if ($srcVerPart < $compareVer[$i]) {
                    return -1;
                }
            }
        }

        return 0;
    }
public function compareVersions($sourceVer, $compareVer)
    {
        $sourceVer = explode('.', $sourceVer);
        foreach ($sourceVer as $k => $v) {
            $sourceVer[$k] = $this->parseInt($v);
        }

        $compareVer = explode('.', $compareVer);
        foreach ($compareVer as $k => $v) {
            $compareVer[$k] = $this->parseInt($v);
        }

        if (count($sourceVer) != count($compareVer)) {
            if (count($sourceVer) > count($compareVer)) {
                for ($i = count($compareVer); $i < count($sourceVer); $i++) {
                    $compareVer[$i] = 0;
                }
            } else {
                for ($i = count($sourceVer); $i < count($compareVer); $i++) {
                    $sourceVer[$i] = 0;
                }
            }
        }

        foreach ($sourceVer as $i => $srcVerPart) {
            if ($srcVerPart > $compareVer[$i]) {
                return 1;
            } else {
                if ($srcVerPart < $compareVer[$i]) {
                    return -1;
                }
            }
        }

        return 0;
    }
public function compareVersions ( $ sourceVer , $ compareVer ) { $ sourceVer = explode ( '.' , $ sourceVer ) ; foreach ( $ sourceVer as $ k => $ v ) { $ sourceVer [ $ k ] = $ this -> parseInt ( $ v ) ; } $ compareVer = explode ( '.' , $ compareVer ) ; foreach ( $ compareVer as $ k => $ v ) { $ compareVer [ $ k ] = $ this -> parseInt ( $ v ) ; } if ( count ( $ sourceVer ) != count ( $ compareVer ) ) { if ( count ( $ sourceVer ) > count ( $ compareVer ) ) { for ( $ i = count ( $ compareVer ) ; $ i < count ( $ sourceVer ) ; $ i ++ ) { $ compareVer [ $ i ] = 0 ; } } else { for ( $ i = count ( $ sourceVer ) ; $ i < count ( $ compareVer ) ; $ i ++ ) { $ sourceVer [ $ i ] = 0 ; } } } foreach ( $ sourceVer as $ i => $ srcVerPart ) { if ( $ srcVerPart > $ compareVer [ $ i ] ) { return 1 ; } else { if ( $ srcVerPart < $ compareVer [ $ i ] ) { return - 1 ; } } } return 0 ; }
Compare two version number strings.
@param string $sourceVer The source version number.
@param string $compareVer The version number to compare with the source version number.
@return int Returns -1 if $sourceVer < $compareVer, 0 if $sourceVer == $compareVer or 1 if $sourceVer >
$compareVer.
Compare two version number strings .