note 102318 modified in function.mt-rand by aharvey
| From: | aharvey@php.net | Date: | Fri, 18 Mar 2011 04:20:07 +0000 |
| Subject: | note 102318 modified in function.mt-rand by aharvey | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-177971@lists.php.net to get a copy of this message | ||
[Editor's note: Minor error in a magic constant and a syntax error fixed. You may also want to
consider using uniqid(), depending on your needs.]
This will result in an EXTREMELY fast random string using the following characters:
"0123456789abcdefghijklmnopqrstuvwxyz"
you can use:
<?php
base_convert(mt_rand(0x1D39D3E06400000, 0x41C21CB8E0FFFFFF), 10, 36);
?>
This will be a random number/string always 12 characters. This will only work on 64 bit systems.
This will result in a random number/string between: 100000000000 to zzzzzzzzzzzz If you are using a
32 bit system you will need to use:
<?php
base_convert(mt_rand(0x19A100, 0x39AA3FF), 10, 36);
?>
This will result in a 5 character random number/string, between: 10000 to zzzzz
--was--
This will result in an EXTREMELY fast random string using the following characters:
"0123456789abcdefghijklmnopqrstuvwxyz"
you can use:
<?php
base_convert(mt_rand(0x1D39D3E06400000, 0x41C21CB8E0FFFFFF), 10, 36);
?>
This will be a random number/string always 12 characters. This will only work on 64 bit systems.
This will result in a random number/string between: 100000000000 to zzzzzzzzzzzz If you are using a
32 bit system you will need to use:
<?php
base_convert(mt_rand(0x1679616, 0x39AA3FF, 10, 36);
?>
This will result in a 5 character random number/string, between: 10000 to zzzzz
http://php.net/manual/en/function.mt-rand.php