Created
July 16, 2015 05:17
-
-
Save kubaceg/96fb4881bfa816239af6 to your computer and use it in GitHub Desktop.
Simple one function PHP progress bar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @param int $done | |
* @param int $total | |
*/ | |
function progress($done, $total) | |
{ | |
$totalSeg = 20; | |
$seq = intval(($done / $total) * $totalSeg); | |
$str = "[" . str_repeat('=', $seq) . str_repeat(' ', $totalSeg - $seq) . "] $done/$total"; | |
echo "\r$str"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment