I have form:
<form method="post">
<textarea name="add" cols="50" rows="20"></textarea>
<br>
<input type="submit" formaction="make.php" value="MAKE"><br><br><br>
</form>
I post few rows using this form such as:
lala
lalal12
blabla
Also I have big txt file words.txt. I need to take random 1000 rows from this file and put them into lala.txt, lalal12.txt, blabla.txt-1000 different random rows to each file. I tried to do:
<?php
$words = file_get_contents('words.txt');
$add = $_POST[add];
if (isset($add)) {
$arr = explode( "\n", $add);
foreach($arr as $row) {
shuffle($words);
$out = array_slice($words, 0, 1000);
$out = implode("\n", $out);
file_put_contents($row.'.txt', $out);
}
}
but it doesn't work. Please help me with it.