title: php find value in array range
body: <p>I have the following array:</p>
  
  <pre><code>$groupA= array(1,10);
  $groupB = array(11,20);
  $groupC = array(21,30);
  </code></pre>
  
  <p>The user has the possibility to enter any numeric value into a text-box, for example "5" now I need to display the user in which group that number is. I've done this before this way:</p>
  
  <p>And then do a switch case like this:</p>
  
  <pre><code>switch ($input){
      case ($input&gt;= $groupA[0] &amp;&amp; $input&lt;= $groupA[1]):
          echo "You are in Group A.";
      break;
      case ($input&gt;= $groupB[0] &amp;&amp; $input&lt;= $groupB[1]):
          echo "You are in Group B.";
      break;
  </code></pre>
  
  <p>However, this seems not feasable since we have got many many groups (likely over 200) and using this many switch-cases is unefficient.</p>
  
  <p>Any ideas on how to solve this more elegantly?</p>