title: Is there any syntax or command in php to check whether a number is in a set of numbers?
body: <p>I come from another language, so I miss this feature on php. For example, if I want to check whether if a number is 2, 4, between 7 to 10, or 15, I would like to express it as:</p>
  
  <pre><code>if ($x in [2, 4, 7...10, 15]) { do_something(); }
  </code></pre>
  
  <p>Instead of:</p>
  
  <pre><code>if ($x == 2 || $x == 4 || ($x &gt;= 7 &amp;&amp; $x &lt;= 10) || $x == 15) { do_something(); }
  </code></pre>
  
  <p>Or:</p>
  
  <pre><code>switch ($x) {
  case 2:
  case 4:
  case 7:
  case 8:
  case 9:
  case 10:
  case 15:
      do_something();
      break;
  }
  </code></pre>
  
  <p>Or even:</p>
  
  <pre><code>switch (true) {
  case ($x == 2):
  case ($x == 4):
  case ($x &gt;= 7 &amp;&amp; $x &lt;= 10):
  case ($x == 15):
      do_something();
      break;
  }
  </code></pre>
  
  <p>Is there any way in php to do that or workaround similar to that? I use this comparison a lot in my code, and the "in set" format makes my code much more readable and less error-prone (writing <code>7...10</code> is safer than writing <code>x &gt;= 7 &amp;&amp; x &lt;= 10</code>). Thanks.</p>