/ Published in: PHP

I needed a way to generate some random strings for passwords, a number of methods seemed a little over the top so below is my simplified version that does the trick. I have set it to use non-confusing characters, so no i's, l's, 0's but very easy to change.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php /* * str_shuffle to generate a random series of characters based on those provided, uniqid added, then shuffled again. * substr will trim the output down to between 10 and 12 characters randomly. */ //Generate 10 Random Strings $i = 1; while($i <= 10){ echo substr(str_shuffle(uniqid(str_shuffle("abcdefghjkmnpqrstwxyzABCDEFGHJKMNPQRSTWXYZ23456789"))), 0, rand(10,12))."<br/>"; $i++; } ?>
Comments
