Sixem

PHP Random String in PHP

Jun 14th, 2013
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.30 KB | None | 0 0
  1. <?php
  2. function RandomString($length = 10) {
  3. $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
  4.     $randomString = '';
  5.     for ($i = 0; $i < $length; $i++) {
  6.         $randomString .= $characters[rand(0, strlen($characters) - 1)];
  7.     }
  8.     return $randomString;
  9. }
  10. ?>
Advertisement
Add Comment
Please, Sign In to add comment