Joke Collection Website - Talk about mood - Tell me about 3333333

Tell me about 3333333

Let's talk about ideas first:

1. First, get the contents of file 1.txt, and cut it according to the line break to get an array $ex 1.

2. Cut the contents of file2.txt into the array $ex2 in the same way.

3. Cycle $ex 1 array (it should be file 1.txt file2.txt, and cycle file 1.txt when the number of rows is different).

Set a random number in the loop.

Combine the corresponding contents in $ ex1$ ex 2 into a record and save it to file3.txt

Finally, file3.txt is the result you want.

Display code:

& lt? Server-side programming language (abbreviation of professional hypertext preprocessor)

//Predefined variables

$ contents 1 =“”;

$ contents 2 =“”;

$ contents 3 =“”;

//Get the contents of file 1

$ contents 1 = file _ get _ contents(' file 1 . txt ');

//Cut the array with line breaks

$ex 1 = explode('

,$ contents 1);

//Get the contents of file 1

$ contents 2 = file _ get _ contents(' file 2 . txt ');

//Cut the array with line breaks

$ex2 = explosion ('

,$ contents 2);

$ count 1 = count($ ex 1);

$ count 2 = count($ ex2);

//Loop values and assign values

for($ I = 0; $ i & lt$ count 1; $i++){

//Set the random number

$j = rand(0,$ count 1- 1);

Content 3. = $ex 1[$j]。 $ex2[$i]。 '

;

}

//Write file

file_put_contents('file3.txt ',$ contents 3);

You can copy this code and create a new file 1.txt file2.txt to write the corresponding test content (note that the line has been broken).

test