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.

Recommended Answers

All 2 Replies

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.

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;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.