$ mix - array combines arrays with words separated by spaces. array_unique in this case does not work and the words are duplicated at the output.
$mix = array_merge($arr_mix_1, $arr_mix_2, $arr_mix_3); $mixed = array_unique($mix); shuffle($mixed); $result = implode(' ', $mixed); Well, I know that how the textbook works. And my code does not work. It was necessary to immediately lay out the entire code for evaluation.
<?php $rand_a = rand(700,900); $rand_b = rand(500,700); $rand_c = rand(30,40); $arr_1 = explode(' ', file_get_contents('data/big_file.txt')); shuffle($arr_1); $a = -1; while (++$a <= $rand_a) { $arr_mix_1[] = $arr_1[$a]; } $arr_2 = explode(' ', file_get_contents('data/key_file.txt')); shuffle($arr_2); $b = -1; while (++$b <= $rand_b) { $arr_mix_2[] = $arr_2[$b]; } $arr_3 = explode(' ', file_get_contents('data/must_have_file.txt')); shuffle($arr_3); $c = -1; while (++$c <= $rand_c) { $arr_mix_3[] = $arr_3[$c]; } $mix = array_merge($arr_mix_1, $arr_mix_2, $arr_mix_3); $mixed = array_unique($mix); shuffle($mixed); $result = implode(' ', $mixed); ?>