Jump to content

php percent


karimali831

Recommended Posts

Hi,

 

Example:

 

echo percent(5, 10, 2)."%";

gives you 50%

 

Instead of this representation, I want to use a bar like this:

activity4.png

 

So what ever percentage it is, it will show on the bar. (out of 100%)

 

anyone help me achieve this please?

 

Thanks

 

function percent($sub, $total, $dec) {
if ($sub) {
	$perc = $sub / $total * 100;
	$perc = round($perc, $dec);
	return $perc;
}
else return 0;
}

Link to comment
https://forums.phpfreaks.com/topic/217794-php-percent/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.