function fp_get_random_string

6.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.

File

includes/misc.inc, line 400
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;

}