title: How do I limit an integer to a maxium value in PHP?
body: <p>I am unsure if a function exists already because while searching for limiting an integer to a maximum number all I found was results for what the maximum number an integer can hold.</p>
  
  <p>I am looking for the function (if it exists) to replace the intLimit in the following code:</p>
  
  <pre><code>&lt;?php
      $x = intLimit(1,20); // $x = 1;
      $x = intLimit(9.6,20); // $x = 9.6;
      $x = intLimit(41,20); // $x = 20;
      $x = intLimit(1932,20); // $x = 20;
      $x = intLimit(21,20); // $x = 20;
  
      $x = intLimit(1,40); // $x = 1;
      $x = intLimit(9.6,40); // $x = 9.6;
      $x = intLimit(41,40); // $x = 40;
      $x = intLimit(1932,40); // $x = 40;
      $x = intLimit(21,40); // $x = 21;
  ?&gt;
  </code></pre>