leetcode --165--php

class Solution {

    /**
     * @param String $version1
     * @param String $version2
     * @return Integer
     */
function compareVersion($versionA, $versionB) {
        //$verListA = str_split($versionA);
        //$verListB = str_split($versionB);
    $dm = '.';
    $verListA = explode($dm, (string)$versionA);
    $verListB = explode($dm, (string)$versionB);
        $len1 = count($verListA);
        $len2 = count($verListB);
//      echo $len1 . PHP_EOL;
//      echo $len2 . PHP_EOL;
        $max = max($len1, $len2);
        for ($i = 0; $i < $max; $i++) {
                $temp1 = 0;
                $temp2 = 0;
                if (i < $len1) {
                        $temp1 = intval($verListA[$i]);
                }
                if (i < $len2) {
                        $temp2 = intval($verListB[$i]);
                }
                if ($temp1 != $temp2) {
                        return $temp1 > $temp2 ? 1 : -1;
                }
        }
        return 0;
}

}