More elegant way of adding a percentage?

tan_alec

New Member
I'm wondering if there is a more elegant way of adding a percentage. For example, if I wanted to add 12% of \[code\]$a\[/code\]'s value to \[code\]$a\[/code\] I'm doing:\[code\]$a = 100;$a = $a + (($a / 100) * 12);\[/code\]Which gives me \[code\]112\[/code\] as the new value, of course. But I can't help but feel this is a little too verbose and there must be a better way of doing the percentage addition.I tried:\[code\]$a = $a + 12%;\[/code\]But, as expected this doesn't work. Before I consider writing a function myself to make this easier, is there a pre-existing way to do this?
 
Back
Top