Last active
July 10, 2018 14:15
-
-
Save DavMorr/93268e3eb753ea00512d32e6b236e878 to your computer and use it in GitHub Desktop.
Generate a number from an alphanumeric string. Has limited utility and no suggestion of identity uniqueness.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function getNumKey($str) { | |
$alpha = range('A', 'Z'); | |
$chars = str_split(strtoupper($str)); | |
foreach ($chars as $char) { | |
$x = (is_numeric($char)) ? $char : (array_search($char, $alpha) + 1); | |
$numz += $x; | |
// echo $x.' '; | |
} | |
return $numz; | |
} | |
$str = 'CHCH1CH2DKDK4'; | |
$numkey = getNumKey($str); | |
// echo '<hr>' . $numkey; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment