a random character from a string of characters 3a

Solutions on MaxInterview for a random character from a string of characters 3a by the best coders in the world

showing results for - "a random character from a string of characters 3a"
Eric
04 Oct 2018
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);
Oprah
08 Aug 2019
1String chars = "abcxyz";
2Random rnd = new Random();
3char c = chars.charAt(rnd.nextInt(chars.length()));
4
similar questions