Return to Snippet

Revision: 40668
at July 22, 2011 09:53 by motlive


Updated Code
<?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++;
}

?>

Revision: 40667
at February 5, 2011 00:29 by motlive


Updated Code
<?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){
substr(str_shuffle(uniqid(str_shuffle("abcdefghjkmnpqrstwxyzABCDEFGHJKMNPQRSTWXYZ23456789"))), 0, rand(10,12))."<br/>";
$i++;
}

?>

Revision: 40666
at February 5, 2011 00:19 by motlive


Updated Code
<?php 

/*
* Uses uniqid and str_shuffle to generate a random series of characters based on those provided.
* substr will trim the output down to between 10 and 12 characters randomly. 
*/

//Generate 10 Random Strings
$i = 1;
while($i <= 10){
echo substr(uniqid(str_shuffle("abcdefghjkmnpqrstwxyzABCDEFGHJKMNPQRSTWXYZ23456789")), 0, rand(10,12))."<br/>";
$i++;
}

?>

Revision: 40665
at February 5, 2011 00:15 by motlive


Initial Code
<?php 

/*
* Uses uniqid and str_shuffle to generate a random series of characters based on those provided.
*/

//Generate 10 Random Strings
$i = 1;
while($i <= 10){
echo substr(uniqid(str_shuffle("abcdefghjkmnpqrstwxyzABCDEFGHJKMNPQRSTWXYZ23456789")), 0, rand(10,12))."<br/>";
$i++;
}

?>

Initial URL

                                

Initial Description
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.

Initial Title
Super Easy Random String Generator - Useful for Passwords

Initial Tags
php

Initial Language
PHP