Skip to content

Instantly share code, notes, and snippets.

@enix-app
Forked from mayconbordin/progress_bar.php
Created September 10, 2020 05:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save enix-app/0e8990e59e221642aa5035b357f013e3 to your computer and use it in GitHub Desktop.
Save enix-app/0e8990e59e221642aa5035b357f013e3 to your computer and use it in GitHub Desktop.
PHP CLI progress bar in 5 lines of code
<?php
function progress_bar($done, $total, $info="", $width=50) {
$perc = round(($done * 100) / $total);
$bar = round(($width * $perc) / 100);
return sprintf("%s%%[%s>%s]%s\r", $perc, str_repeat("=", $bar), str_repeat(" ", $width-$bar), $info);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment