note 101075 deleted from function.mt-rand by danbrown
| From: | danbrown@php.net | Date: | Tue, 08 Feb 2011 15:58:58 +0000 |
| Subject: | note 101075 deleted from function.mt-rand by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-176781@lists.php.net to get a copy of this message | ||
Note Submitter: thegreatall at gmail dot com
----
If you want to generate an EXTREMELY FAST random serial using
'0123456789abcdefghijklmnopqrstuvwxyz' you can use:
<?php
base_convert(mt_rand(0, 0x38E38E38E38E38E), 10, 36);
?>
You may need to change the 0x38E38E38E38E38E to whatever your (PHP_INT_MAX / 36) is. that number is
for 64 bit machines, 32 bit machines will be: 0x38E38E3. on on 64 bit machines it gives roughly
between a 1 to 12 character number. on a 32 bit machine it will return roughly 1 to 5 characters.
If you do some simple math you can get it to always return a certain number of characters.