How can increase a number according to percent with PHP?
For example: 100 + 20% = 120 or 1367 + 33% = 1818.11
If output was this: 1818.11 i want only this: 1818 or this 12.32 = 12 or 546.98 = 546
How is it?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I’m not sure if you’re looking for something deeper, but the answer seems fairly straightforward…
If you wrapped that in a function, say
increaseByPercentage( $value, $percentageIncrease ), you would get…Edit
Based on your comment, I’m not sure what else you are looking for. PHP has 6 arithmetic operators:
Negation (-$a)
-5 = -5
Addition ($a + $b)
5 + 3 = 8
Subtraction ($a – $b)
5 – 3 = 2
Multiplication ($a * $b)
5 * 3 = 15
Division ($a / $b)
5 / 3 = 1.667
Modulus ($a % $b)
5 % 3 = 2
If you write a line of code that says
$a = 100 + 20%;it will not parse.