Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. red
  2. pink
  3. purple
  4. deep purple
  5. indigo
  6. blue
  7. light blue
  8. cyan
  9. teal
  10. green
  11.  
  12. <?php
  13. $file = fopen("files.txt","r");
  14.  
  15. while(! feof($file))
  16. {
  17. echo fgets($file). "<br />";
  18. $fileName = fgets($file);
  19. $myfile = fopen($fileName.'.txt, "w");
  20.  
  21. }
  22.  
  23. fclose($file);
  24. ?>
  25.  
  26. $handle = fopen("path/to/files.txt", "r");
  27. $filesToCreate = [];
  28. if ($handle) {
  29. while (($line = fgets($handle)) !== false) {
  30.  
  31. // you may need to add the full path here..
  32. $filesToCreate[] = $line . '.txt';
  33. }
  34.  
  35. fclose($handle);
  36. } else {
  37. // error opening the file.
  38. }
  39.  
  40. foreach ($filesToCreate as $newFile) {
  41. $createdFile = fopen($newFile, 'w');
  42. fclose($createdFile);
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement