PHP Salt


A little dash of PHP... my collection of php functions

Version: 2.14.1
Last Build: March 10, 2017 13:28pm (PST)

psPercentAdd()
Add a percentage.


Description:

Simple way to add a percentage to a value


Usage:

$val = psPercentAdd($num,$per);
$num = a number to add percentage to
$per is the percentage, ie: 13.75 percent
Note: % sign is optional


Example:

	$num = 100.00;
$per = 13.75;
$val = psPercentAdd($num,$per);
// $val will be 113.75



Code:

function psPercentAdd($num,$per)
{
$per = str_replace("%","",$per);
$res = $num + ( $num * ($per / 100) );
return $res;
}

Changlelog:


See Also

And a shot out to:

LinuxSimple - www.linuxsimple.com
PHP - php.net
Fedora Server - getfedora.com
Shameless ads to pay for site