Generate Password Snippet by neon
Design & Code :: Coding :: PHP & MySQL
Page 1 of 1 • Share •
Generate Password Snippet by neon
- Code:
<?php
define('CHARS_ALPHA', 'abcdefghijklmnopqrstuvwxyz');
define('CHARS_DIGIT', '0123456789');
function get_random_variable()
{
$o = substr(str_shuffle(CHARS_ALPHA), 0, 1);
for($i = 0; $i < 2 + rand() % 9; $i++)
{
$c = str_shuffle(strtolower(CHARS_ALPHA) . strtoupper(CHARS_ALPHA) . CHARS_DIGIT);
$o .= $c[0];
}
return $o;
}
echo get_random_variable();
?>

~Fleck- Moderator

- Posts: 274
Activity: -258
Reputation: 8
Join date: 2009-06-28
Age: 16
Location: 127.0.0.1
Re: Generate Password Snippet by neon
This code is very easy, but i like to use array_rand() instead of shuffel.
_________________

"You tried, gave your best, and failed. Here's the lesson: "Never try!""
~Homer Simpson

misterx- Admin

- Posts: 59
Activity: -702
Reputation: 1
Join date: 2009-06-27
Age: 14
Location: Estonia
Permissions of this forum:
You cannot reply to topics in this forum
Home


