note 102318 modified in function.mt-rand by danbrown
| From: | danbrown@php.net | Date: | Tue, 08 Feb 2011 15:59:05 +0000 |
| Subject: | note 102318 modified in function.mt-rand by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-176782@lists.php.net to get a copy of this message | ||
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
--was--
Correction to what I said before about the fast random number/serial. 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