Skip to content

Instantly share code, notes, and snippets.

@necenzurat
Created October 1, 2012 07:49
Show Gist options
  • Save necenzurat/3810169 to your computer and use it in GitHub Desktop.
Save necenzurat/3810169 to your computer and use it in GitHub Desktop.
rand shit
<?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