title: Best way to check if all array values are in a range
body: <p>How is best way to check if all array values are in range?</p>
  
  <p>For example:</p>
  
  <pre><code>$range = range(10, 40);
  
  $array1 = array(10, 20, 40); // OK 
  $array2 = array(11, 22, 42, 30); // FALSE 
  $array3 = array(50); // OK 
  $array4 = array(10, 20, 30, 'a'); // FALSE 
  $array5 = array("%", 20); // FALSE 
  $array6 = array(10, 20, 40, 39, 40); // OK 
  </code></pre>
  
  <p>So how can I check if array values are numbers (integer) and are in range?</p>
  
  <p>I tried:</p>
  
  <pre><code>$tmp = 0;
  foreach ($array1 as $a1) {
     if (!in_array($a1, $range) &amp;&amp; is_int($a1)) {
        $tmp++;
     }
  }
  
  if ($tmp &gt; 0) {
     echo "false";
  } else {
  echo "ok";
  }
  </code></pre>
  
  <p>Maybe is better way? Maybe with <code>array_map()</code>?</p>