From 3782e71ae6df9d0198e43b1288feb7599c4171e6 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Mon, 20 Oct 2025 12:42:31 +0200 Subject: [PATCH] add method makeRandomString() --- inc/inc.Utils.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/inc/inc.Utils.php b/inc/inc.Utils.php index 67dbd7d0c..6c1aa9c44 100644 --- a/inc/inc.Utils.php +++ b/inc/inc.Utils.php @@ -1293,6 +1293,20 @@ class SeedDMS_Utils { /* {{{ */ } } /* }}} */ + /** + * Create a random string + * + * @param integer $n number of chars + * @param string $alph alphabet used as source for chars + * @return string random string + */ + static public function makeRandomString($n, $alph = "0123456789abcdefghijklmnopqrstuvwxyz") { /* {{{ */ + $s = ""; + for ($i = 0; $i != $n; ++$i) + $s .= $alph[mt_rand(0, 35)]; + return $s; + } /* }}} */ + } /* }}} */ /**