note 101075 added to function.mt-rand
| From: | thegreatall at gmail dot com | Date: | Wed, 24 Nov 2010 15:25:46 +0000 |
| Subject: | note 101075 added to function.mt-rand | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-174326@lists.php.net to get a copy of this message | ||
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.
----
Server IP: 69.147.83.197
Probable Submitter: 12.71.233.34
----
Manual Page -- http://www.php.net/manual/en/function.mt-rand.php
Edit -- https://master.php.net/note/edit/101075
Del: integrated -- https://master.php.net/note/delete/101075/integrated
Del: useless -- https://master.php.net/note/delete/101075/useless
Del: bad code -- https://master.php.net/note/delete/101075/bad+code
Del: spam -- https://master.php.net/note/delete/101075/spam
Del: non-english -- https://master.php.net/note/delete/101075/non-english
Del: in docs -- https://master.php.net/note/delete/101075/in+docs
Del: other reasons-- https://master.php.net/note/delete/101075
Reject -- https://master.php.net/note/reject/101075
Search -- https://master.php.net/manage/user-notes.php