В конце каждой третей строки вставить текст


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <?php
  2.  
  3. $dir = 'D:\Activity\MyDoor2\temp\tmp'; // папка с ткст файлами
  4. $files = glob( $dir . '\*.txt' );
  5.  
  6. foreach ( $files as $file )
  7. {
  8. $strings = file($file);
  9.  
  10. $counter = 1;
  11. $s = '';
  12. foreach( $strings as $string )
  13. {
  14. if ( $counter == 3 )
  15. {
  16. ", "\n"), array('', ''), $string) . '<!--more-->' . "
  17. ";
  18. $counter = 0;
  19. }
  20. else
  21. {
  22. $s .= $string;
  23. }
  24. $counter++;
  25. }
  26. file_put_contents( $file, $s );
  27. }
  28.  
  29. ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.