Created
April 19, 2017 23:56
-
-
Save oscarmarcelo/294009f6605535ebb9179cffc8a61de3 to your computer and use it in GitHub Desktop.
Generate an identifier code for invoices
This file contains 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 | |
define('KEY_CHARS', 'ACEFGHJKPQRSTWXYZ23456789'); // characters which cannot be confused phonetically or by bad handwriting | |
function generate_code($len = 6) { | |
$k = str_repeat('.', $len); | |
while ($len--) { | |
$k[$len] = substr(KEY_CHARS, mt_rand(0, strlen(KEY_CHARS) - 1), 1); | |
} | |
return $k; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment