Jump to content

Random String


brmcdani

Recommended Posts

Iam tring to pull a random string out of an array.  I have it working but it output's 2 strings and I just want it to output 1.  I have tried changing the code up from $keys = array_rand($rand, 2); to $keys = array_rand($rand, 1); but it still won't work.  Here is my complete code snippet:

 

$rand = array("asfd", "ghdg", "kfdr", "sdas", "hdsa", "gdsd", "ijko");

$keys = array_rand($rand, 2);

echo "Verification letters:  ";

echo $rand[$keys[0]] . "\n";

echo $rand[$keys[1]] . "\n";

Link to comment
https://forums.phpfreaks.com/topic/181170-random-string/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.