Hello, friends! I am writing a generator of fake personalities, the problems begin even in such a tiny piece of code - the data is duplicated at regular intervals. If the output is longer - "Last Name First Name Patronymic Address Telephone, etc.", then repeated result lines go every 30 lines. When I deduce only surnames and indexes - each 100 lines. No, I believe that the randomizer can pull out the same last name from the archive of surnames periodically, but that he did it every 100 lines and generated the same six-digit index to it - thank you, my ideas ran out.

Loaded the same script on the hosting, there was updated the page - like duplicates did not notice. I am writing in NetBeans 8.0.2, output to localhost.

//Хватаем случайную фамилию $famtxt = file('surname.txt'); $surname = $famtxt[ array_rand($famtxt) ]; unset($famtxt); //Общий вывод $result0=$surname.' '.rand(100000, 999999); $resulttxt = fopen('result2.txt', 'a'); fwrite($resulttxt,$result0); 
  • Does the problem occur when executing PHP code on Windows? - Vladimir Martyanov

1 answer 1

The situation you described, but forgot to ask a question.

If you are interested in the reason, then the problem is absolutely exactly in your software, most likely with the php interpreter. More specifically, with a pseudo-random number generator. Code you wrote a worker. For the sake of interest, he scored the document with blanks and checked it.

If you are interested in ways to fix this problem, then try to start with a banal reboot -> reinstall -> contact the support of the software developer. You can try your luck with the srand () function (although this is unlikely).

If you are interested in workaround options, then you can install another software product or continue writing the script directly on the hosting.

  • Thank! On the hosting took off perfectly. The question was, in general, where does the problem with the looping results come from? Some suspicions were on the pseudo-random number generator, but then I decided that there are no such frank holes in the development environments. There are, it turned out. - Yaroslav
  • To reduce the chance of repetition, I would add a variable weight for each value, increasing with each use of the value. The code will be more, but the uniqueness of the result is higher. And it will also be possible to control the frequency of using the values ​​(for example, you need to use the name Ivan more often, and less often the patronymic Petrovich. Initially, you set the weight for Ivan and higher for Petrovich). - terantul