public static function getISBN13CheckDigit($isbn)
    {
        $sum = 0;
        $weight = 1;
        for ($x = 0; $x < strlen($isbn); $x++) {
            $sum += intval(substr($isbn, $x, 1)) * $weight;
            $weight = $weight == 1 ? 3 : 1;
        }
        $retval = 10 - ($sum % 10);
        return $retval == 10 ? 0 : $retval;
    }
public static function getISBN13CheckDigit($isbn)
    {
        $sum = 0;
        $weight = 1;
        for ($x = 0; $x < strlen($isbn); $x++) {
            $sum += intval(substr($isbn, $x, 1)) * $weight;
            $weight = $weight == 1 ? 3 : 1;
        }
        $retval = 10 - ($sum % 10);
        return $retval == 10 ? 0 : $retval;
    }
public static function getISBN13CheckDigit ( $ isbn ) { $ sum = 0 ; $ weight = 1 ; for ( $ x = 0 ; $ x < strlen ( $ isbn ) ; $ x ++ ) { $ sum += intval ( substr ( $ isbn , $ x , 1 ) ) * $ weight ; $ weight = $ weight == 1 ? 3 : 1 ; } $ retval = 10 - ( $ sum % 10 ) ; return $ retval == 10 ? 0 : $ retval ; }
Given the first 12 digits of an ISBN-13, generate the check digit.

@param string $isbn The first 12 digits of an ISBN-13.

@return string      The check digit.
Given the first 12 digits of an ISBN - 13 generate the check digit .