Created
December 30, 2023 20:04
-
-
Save fakerybakery/5e8b424bf08e76b93b3b16317c3c1e29 to your computer and use it in GitHub Desktop.
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
<?php | |
# License: MPL 2.0 (Mozilla Public License, version 2.0) | |
# Copyright: Copyright (c) 2023 mrfakename <mrfake.name>. All rights reserved, except as licensed under the Mozilla Public License, version 2.0 | |
$ptext = "Progress: | |"; | |
echo $ptext; | |
for ($percent = 0 ; $percent <= 100 ; $percent++) { | |
echo "\033[" . strlen($ptext) . "D"; | |
$x = round(($percent / 10) * 2); | |
echo "Progress: | " . str_repeat("•", $x) . str_repeat(" ", 20 - $x) . " |"; | |
usleep(50000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment