Return to Snippet

Revision: 24283
at February 25, 2010 06:51 by gauravjassal


Initial Code
// Usage progress($currentPostion,$totalResults);

function progress($current,$total,$label = "")
	{
		if($current == 0)
		{
			if($label == "")
			{
				echo "Progress: ";
			}else{
				echo $label;
			}
			
		}else{
			echo $current . " of " . $total;
			
			$totalBackspaces = 4;
			
			$totalBackspaces += strlen($current . "");
			
			$totalBackspaces += strlen($total . "");
			for($i=1;$i <= $totalBackspaces;$i++)
			{
				echo "\010";
			}
			
			
		}
	}

Initial URL


Initial Description


Initial Title
PHP CLI Progress bar

Initial Tags


Initial Language
PHP