0

Hi

$asking_price = "20";		
$original_value = "100";
$discount = (1-($askingPrice/$original_value))*100;
echo $discount;

why $discount always equal to 100 ?
it supposed to be 80.

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by ofir0803
0

I think that you need to work on your debugging skills! $askingPrice is not the same as $asking_price. $askingPrice = 0 so the result is (1-0)* 100 = 100.

0

I think that you need to work on your debugging skills! $askingPrice is not the same as $asking_price. $askingPrice = 0 so the result is (1-0)* 100 = 100.

sorry.

got it

$discount = (1-((int)$asking_price/(int)$original_value))*100;
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.