Skip to content

Instantly share code, notes, and snippets.

@Hywan
Created November 30, 2013 06:47
Show Gist options
  • Save Hywan/7716125 to your computer and use it in GitHub Desktop.
Save Hywan/7716125 to your computer and use it in GitHub Desktop.
A simple progress bar with Hoa\Console.
<?php
require '/usr/local/lib/Hoa/Core/Core.php';
$progress = 1;
$width = Hoa\Console\Window::getSize()['x'] - 2;
$pattern = '%s' . "\n" . '[%-' . $width . 's]';
do {
printf(
$pattern,
$progress,
str_repeat('#', ($progress * $width) / 100)
);
sleep(1);
Hoa\Console\Cursor::clear('↔');
} while(($progress += mt_rand(5, 20)) <= 100);
echo "\n\n", 'DONE!', "\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment