function fp_get_random_string

6.x misc.inc fp_get_random_string($len = 7, $alpha = TRUE, $numeric = TRUE, $symbols = FALSE)
7.x misc.inc fp_get_random_string($len = 7, $alpha = TRUE, $numeric = TRUE, $symbols = FALSE)
5.x misc.inc fp_get_random_string($len = 7, $alpha = TRUE, $numeric = TRUE, $symbols = FALSE)

Returns a random string of length len.

1 call to fp_get_random_string()
student_files_handle_upload in modules/student_files/student_files.module
Handles the upload of a file which we assume is located at $_FILES["student_file_upload_file"], or the provided $file array.

File

includes/misc.inc, line 965
This file contains misc functions for FlightPath

Code

function fp_get_random_string($len = 7, $alpha = TRUE, $numeric = TRUE, $symbols = FALSE) {

  $base = "";
  if ($alpha) {
    $base .= "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
  }
  if ($numeric) {
    $base .= "12345678901234567890";
  }
  if ($symbols) {
    $base .= "!@#$%^&*()_+!@#$%^&*()-=";
  }

  $str = "";
  for ($t = 0; $t < $len; $t++) {
    $base = str_shuffle($base);
    $str .= $base [0];
  }

  return $str;

}