Guest User

Untitled

a guest
Jul 21st, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. echo '<script type="text/javascript> update_progress('.($progress->get_progress()).');</script>';
  2. flush();
  3.  
  4. <?php
  5.  
  6. /**
  7. * Quick and easy progress script
  8. * The script will slow iterate through an array and display progress as it goes.
  9. */
  10.  
  11. #First progress
  12. $array1 = array(2, 4, 56, 3, 3);
  13. $current = 0;
  14.  
  15. foreach ($array1 as $element) {
  16. $current++;
  17. outputProgress($current, count($array1));
  18. }
  19. echo "<br>";
  20.  
  21. #Second progress
  22. $array2 = array(2, 4, 66, 54);
  23. $current = 0;
  24.  
  25. foreach ($array2 as $element) {
  26. $current++;
  27. outputProgress($current, count($array2));
  28. }
  29.  
  30. /**
  31. * Output span with progress.
  32. *
  33. * @param $current integer Current progress out of total
  34. * @param $total integer Total steps required to complete
  35. */
  36. function outputProgress($current, $total) {
  37. echo "<span style='position: absolute;z-index:$current;background:#FFF;'>" . round($current / $total * 100) . "% </span>";
  38. myFlush();
  39. sleep(1);
  40. }
  41.  
  42. /**
  43. * Flush output buffer
  44. */
  45. function myFlush() {
  46. echo(str_repeat(' ', 256));
  47. if (@ob_get_contents()) {
  48. @ob_end_flush();
  49. }
  50. flush();
  51. }
  52.  
  53. ?>
Add Comment
Please, Sign In to add comment