I am wondering if there is a more elegant way to add interest. For example, if I wanted to add 12% of the value of $a to $a , I do:
$a = 100; $a = $a + (($a / 100) * 12);
Which gives me 112 as a new meaning, of course. But I cannot help but feel that this is too verbose, and there should be a better way to make a percentage addition.
I tried:
$a = $a + 12%;
But, as expected, this will not work. Before I start looking at a function myself to make it easier, is there an existing way to do this?
source share