Advertisement
Guest User

Untitled

a guest
Oct 13th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. <?php
  2.  
  3. function processLinesGroup($linesGroup) {
  4. // do something with the group of input lines
  5. }
  6.  
  7. function processInputLines($inputLines) {
  8. $linesGroup = array();
  9. $maxLines = 50;
  10.  
  11. foreach ($inputLines as $line) {
  12. array_push($linesGroup, $line);
  13.  
  14. // Process the group each time it's growing to N items
  15. if (count($linesGroup) === $maxLines) {
  16. processLinesGroup($linesGroup);
  17. $linesGroup = array();
  18. }
  19. }
  20.  
  21. // Process the remaining items in the end
  22. if (!empty($linesGroup)) {
  23. processLinesGroup($linesGroup);
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement