/ Published in: PHP

Testing a couple different ways to create a random string 3 characters long [a-zA-Z0-9]. Turns out mod is pretty quick!
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; for ($i=0; $i<1000000; $i++) { # echo $uid . "\n"; } echo microtime(true) - $timer . ' seconds using rand(0, strlen()-1)' . "\n"; # 1.6855049133301 seconds for ($i=0; $i<1000000; $i++) { # echo $uid . "\n"; } for ($i=0; $i<1000000; $i++) { # echo $uid . "\n"; }
Comments
