Skip to content

Instantly share code, notes, and snippets.

@Itachi261092
Last active September 7, 2018 20:52
Show Gist options
  • Save Itachi261092/2f735d3d7960caa339a94a787c37936a to your computer and use it in GitHub Desktop.
Save Itachi261092/2f735d3d7960caa339a94a787c37936a to your computer and use it in GitHub Desktop.
This is simpliest progress-bar for php scripts
function prgrsbr($oneStep, $maxSteps){
$percent = $oneStep / $maxSteps * 100;
$width = $percent * 10; // CSS property. 1% = 10px / 100% = 1000px
echo '<div style="width:1000px;height:40px;border:1px solid black;"><div style="width:'.$width.'px;height:40px;line-height:40px;background-color:green;text-align:center">'.$percent.'%</div></div>';
}
$iMax = 10000;
for ($i = 1; $i <= $iMax; $i++) {
prgrsbr($i, $iMax);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment