title: subtracting a percentage from a value in php
body: <p>Im writing something similar to a coupon code function, and want to be able to handle both set amount codes, as well as percentage amounts.</p>
  
  <p>My code is as follows;</p>
  
  <pre><code>$amount = "25"; // amount of discount
  $percent = "yes"; // whether coupon is (yes) a percentage, or (no) a flat amount
  
  if($percent == "yes"){
  $newprice = ???????; // subtract $amount % of $price, from $price
  }else{
  $newprice = $price - $amount; // if not a percentage, subtract from price outright
  }
  </code></pre>
  
  <p>Im searching google as you read this looking for a solution but i thought id post it here as well to help others who may encounter same problem.</p>