title: Calculating whether a result falls within 2 percentage variables PHP
body: <p>I am trying to find whether a variable that I am calculating falls within a 20% range of a predefined number.</p>
  
  <p>For example: predefined number is 8 (20% is 1.6) so the number would need to fall between 6.4 and 9.6.</p>
  
  <p>What would be the best way to do this via PHP please?</p>
  
  <p>//------------------- APOLOGIES FOUND A WORKING ANSWER</p>
  
  <p>Apologies worked this out by thinking about it!</p>
  
  <p>Here is the code for others:</p>
  
  <pre><code>// Calculating the variables and defining the top and bottom ($read = 8 for example)
  $calspeed = $read * 0.2;
  $topspeed = $read + $calspeed;
  $btmspeed = $read - $calspeed;
  
  // $avg is taken from a sql query drawn from database
  if ($avg &gt; $btmspeed &amp;&amp; $avg &lt; $topspeed){
      echo "this is an acceptable reading speed";
  }else{
      echo "wrong";
  }
  </code></pre>