How to create a folder with a unique name from a list of characters?

0 like 0 dislike
Need a script that generates the folder name from two lists of symbols - consonants and vowels
see if there is already such a folder on the server

we need to create a folder which has no

a list of consonants: FDTRWQK
a list of consonants: OEAIU
the sequence of letters of the name must be of the form: DADADA
that is, consonants and vowels

$m_1 = array("D", "B", "G", "V", "Z", "J", "R", "L", "M", "N", "H", "C"); $m_2 = array("A", "O", "E", "U", "I"); do { $name = $m_1[array_rand($m_1, 1)] . $m_2[array_rand($m_2, 1)] . $m_1[array_rand($m_1, 1)] . $m_2[array_rand($m_2, 1)] . $m_1[array_rand($m_1, 1)] . $m_2[array_rand($m_2, 1)]; } while (file_exists('folder/'.$name)); mkdir('folder/'.$name);
by | 3 views

2 Answers

0 like 0 dislike
0 like 0 dislike
array_rand() randomic sucks, just rand()

At least a couple of years ago, it ran, array_rand() has started to give out patterns that may or cyclical.


Something on the subject
there is an example of a function obtaining a random string from given characters.
110,608 questions
257,186 answers
33,901 users