0

Possible Duplicate:
Generating (pseudo)random alpha-numeric strings

How to genearte random string in PHP? Numbers are not a problem, but how to deal with letters efficiently?

Community
  • 1
  • 1
ZombieDragon
  • 131
  • 1
  • 2
  • 12

1 Answers1

0

You might be best of using the normal random function in combination with chr From the php manual comments: http://php.net/manual/en/function.chr.php

<?php
for($i=0; $i<7; $i++){
    $random_string .= chr(rand(0,25)+65);
}
echo $random_string;
?>
Nanne
  • 64,065
  • 16
  • 119
  • 163