PHP CLI Progress bar


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



Copy this code and paste it in your HTML
  1. // Usage progress($currentPostion,$totalResults);
  2.  
  3. function progress($current,$total,$label = "")
  4. {
  5. if($current == 0)
  6. {
  7. if($label == "")
  8. {
  9. echo "Progress: ";
  10. }else{
  11. echo $label;
  12. }
  13.  
  14. }else{
  15. echo $current . " of " . $total;
  16.  
  17. $totalBackspaces = 4;
  18.  
  19. $totalBackspaces += strlen($current . "");
  20.  
  21. $totalBackspaces += strlen($total . "");
  22. for($i=1;$i <= $totalBackspaces;$i++)
  23. {
  24. echo "\010";
  25. }
  26.  
  27.  
  28. }
  29. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.