Today I wanted to create some progress indicator PHP command line, after minute googling I found http://forums.devshed.com/php-development-5/php-cli-progress-indicator-151590.html
After slight change:
function progressBar($current, $total, $label) { $percent = round($current / $total * 100); if ($current == 0) { if ($label == "") echo "Progress: \n"; else if ($label != "none") echo $label."\n"; echo "|"; } else { for ($place = 20; $place >= 0; $place--) { echo "\010"; } } for ($place = 0; $place < 15; $place++) { if ($place <= ($percent*0.15)) echo "*"; else echo " "; } echo "| ".sprintf('%3.0f',$percent)."%"; if ($current == $total) { echo "\n"; } } |
