public static function luhn($input) {
        if ($input == 0) {
            return false;
        }

        $sum = 0;
        $length = mb_strlen($input);

        for ($position = 1 - ($length % 2); $position < $length; $position += 2) {
            $sum += $input[$position];
        }

        for ($position = ($length % 2); $position < $length; $position += 2) {
            $number = $input[$position] * 2;
            $sum += ($number < 10) ? $number : $number - 9;
        }

        return ($sum % 10 == 0);
    }
public static function luhn($input) {
        if ($input == 0) {
            return false;
        }

        $sum = 0;
        $length = mb_strlen($input);

        for ($position = 1 - ($length % 2); $position < $length; $position += 2) {
            $sum += $input[$position];
        }

        for ($position = ($length % 2); $position < $length; $position += 2) {
            $number = $input[$position] * 2;
            $sum += ($number < 10) ? $number : $number - 9;
        }

        return ($sum % 10 == 0);
    }
public static function luhn ( $ input ) { if ( $ input == 0 ) { return false ; } $ sum = 0 ; $ length = mb_strlen ( $ input ) ; for ( $ position = 1 - ( $ length % 2 ) ; $ position < $ length ; $ position += 2 ) { $ sum += $ input [ $ position ] ; } for ( $ position = ( $ length % 2 ) ; $ position < $ length ; $ position += 2 ) { $ number = $ input [ $ position ] * 2 ; $ sum += ( $ number < 10 ) ? $ number : $ number - 9 ; } return ( $ sum % 10 == 0 ) ; }
Luhn algorithm.

@param string $input
@return bool
@link http://en.wikipedia.org/wiki/Luhn_algorithm
Luhn algorithm .