PHP Command Line Progress Bar
Jun 20, 2009
1 Comment
A simple progress bar function for php command line (CLI) scripts:
function progressBar($current, $total, $label="Progress: ", $interval=5) {
if ($current == 0) {
echo $label;
// start the bar
echo "| 0%";
} else {
$pos = ($current / $total * 100);
if( fmod($pos, $interval) == 0 ) {
if( $pos >= 10 ) echo "\010";
if( $pos == 100 ) echo "\010";
echo "\010\010\010";
echo "| $pos%";
}
}
// end progress with a new line
if ($current == $total) echo "\n";
}
Reference code: PHP CLI Progress Indicator






1 Comment
Aug 25, 2009 | 4:08 am
Hi KarmaDude,
We would like to invite you to a community of techies, http://www.techiedesi.com.
You are one among the few Techie bloggers we have hand picked to send a special invitation (i.e., this is not an automated mail). We could not get hold of your email so sending this as a comment on your blog.
At TechieDesi Community, we are trying to build the largest community of techies, with the shortest turn around time to get the questions answered. It’s a community of bloggers, geeks, solution providers and all different people who have one thing in common, the interest towards technology.
If you would like to know more about the community, who built it and what are our visions, please follow the links below:
http://www.techiedesi.com/about
As of today, we have more than 700 techies in the community with a few active bloggers and the number is increasing as we spread the word.
We look forward to see you in the community. Please do spread the word to your fellow techies.
Thanks,
TechieDesi Community Management
Leave a Comment
Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>