1function generateRandomString($length = 25) {
2 $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
3 $charactersLength = strlen($characters);
4 $randomString = '';
5 for ($i = 0; $i < $length; $i++) {
6 $randomString .= $characters[rand(0, $charactersLength - 1)];
7 }
8 return $randomString;
9}
10//usage
11$myRandomString = generateRandomString(5);
1String chars = "abcxyz";
2Random rnd = new Random();
3char c = chars.charAt(rnd.nextInt(chars.length()));
4