return to I Love My Journal
A Little Closer to Center...
Musings about Life, Linux, and Latter-day Saints.
Pages
About Me
Links


Tags
PERSONAL 520
SPIRITUAL 416
LDS 312
BOOK OF MORMON 237
SCRIPTURES 154
STUDIO-JOURNEY 129
RELIGION 112
LINUX 79
COMPUTERS 65
LIFE 60
GENERAL CONFERENCE 46
GENTOO 39
MISCELLANEOUS 37
MUSIC 37
PROGRAMMING 33
CARS 29
FAMILY 23
MICROSOFT 23
AUDIO 21
I LOVE MY JOURNAL 18
FUN 15
CHILDREN 12
CURRENT EVENTS 10
NATURE'S WAY 10
VIDEO 9
DRM 9
CONEXM 7
BABBLINGS 7
PROVO CITY CENTER TEMPLE 6
FRIENDS 6
HEROD THE FINK 5
COMPUTER HARDWARE 5
GAMES 5
DRUMS 4
HAND OF GOD 3
AUDIO HARDWARE 3
STUDIO 3
KDENLIVE 3
ADVERSITY 3
GENERAL INSANITY 3
THANKS4GIVING 2
CATS 2
CHURCH NOTES 1
FOREVERGREEN 1
POLITICS 1
POETRY 1
YOUTH CONFERENCE 1
GOSPEL 1
PARENTING 1
MY JOURNAL 1
EVERYDAY THOUGHTS 1


RSS Feed

RSS FeedSubscribe!
Wed - Jul 18, 2007 : 12:12 am
content
   rated 0 times
>>next>>
<<previous<<
Luhn "Mod 10" Algorithm
Whenever I do credit card checking, I always end up searching for longer than it would take me to create it myself, so...  without further ado, here's the Luhn, or "Mod 10" algorithm for validating credit card numbers.

function mod_10($cc) {
    $reversed_string = strrev($cc);
    $string_array = str_split($reversed_string);
    $i=1;
    foreach($string_array AS $character) {
        if($i % 2 == 0) {
            $doubled_array[] = $character * 2;
        } else $doubled_array[] = $character;
        $i++;
    }
    $doubled_string = implode("",$doubled_array);
    $doubled_array2 = str_split($doubled_string);
    $array_sum = array_sum($doubled_array2);
    if($array_sum % 10 == 0) {
        return TRUE;
    } else return FALSE;
}