Skip to content

Instantly share code, notes, and snippets.

@fakerybakery
Created December 30, 2023 20:04
Show Gist options
  • Save fakerybakery/5e8b424bf08e76b93b3b16317c3c1e29 to your computer and use it in GitHub Desktop.
Save fakerybakery/5e8b424bf08e76b93b3b16317c3c1e29 to your computer and use it in GitHub Desktop.
PHP Progress Bar
<?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