Created
October 1, 2012 07:49
-
-
Save necenzurat/3810169 to your computer and use it in GitHub Desktop.
rand shit
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 | |
class zetoken{ | |
const ALPHA = 'abcdefghijklmnopqrstvwxyz'; | |
const NUMERIC = '0123456789'; | |
public static function make( $length = 10, $chars = "" ){ | |
if ($chars == "" ) { | |
$chars .= self::NUMERIC . strtoupper( self::ALPHA ); | |
} | |
$token = ""; | |
for ( $i = 0; $i < $length; $i++){ | |
$token .= $chars[mt_rand( 0, strlen( $chars ) - 1 )]; | |
} | |
return $token; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment