Paste Search Dynamic
random_strings
  1. <?php
  2.  
  3. function random_strings($length_of_string)
  4. {
  5.  
  6.     // String of all alphanumeric character
  7.     $str_result = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
  8.  
  9.     // Shufle the $str_result and returns substring
  10.     // of specified length
  11.     return substr(str_shuffle($str_result),  
  12.                        0, $length_of_string);
  13. }
  14.  
  15. // This function will generate
  16. // Random string of length 10
  17. echo random_strings(10);
  18.  
  19. echo "\n";
  20.  
  21. // This function will generate
  22. // Random string of length 8
  23. echo random_strings(8);
  24.  
  25.  
  26. ?>
Parsed in 0.019 seconds