Given a size N and the task is to generate a random string of size N.
Input: 5 Output: eR3Ds Input: 10 Output: MPRCyBgdcn
Method: Create a domain string which contains small letters, capital letters and the digits (0 to 9). Then generate a random number and pick the character present at that random index and append that character into the answer string.
Below is the program to generate random string using above method:
Random String of length 5 = EEEto
- PHP program to Generate the random number in the given range (min, max)
- How to generate a random, unique, alphanumeric string in PHP
- Generating Random String Using PHP
- How to get random value out of an array in PHP?
- How to generate a drop down list of timezone using PHP ?
- How to Generate Captcha Image in PHP ?
- How to generate an XML file dynamically using PHP?
- PHP | Program to check a string is a rotation of another string
- p5.js | random() Function
- GRE Data Analysis | Distribution of Data, Random Variables, and Probability Distributions
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : ManasChhabra2