title: Group array keys into number ranges, possible?
body: <p><strong>I have the following array:</strong></p>
  
  <pre><code>(
      [25] =&gt; 1
      [26] =&gt; 3
      [10] =&gt; 2
      [24] =&gt; 1
  )
  </code></pre>
  
  <p>It was created using the <a href="http://php.net/manual/en/function.array-count-values.php" rel="nofollow"><code>array_count_values()</code></a> function in PHP.</p>
  
  <p>Actual original array was something like this, before array_count_values... </p>
  
  <pre><code>Array
  (
      [0] =&gt; 26
      [1] =&gt; 
      [2] =&gt; 18
      [3] =&gt; 28
      [4] =&gt; 22
      [5] =&gt; 21
      [6] =&gt; 26
      [7] =&gt; 
      [8] =&gt; 
      [9] =&gt; 
      [10] =&gt; 
      [11] =&gt; 
      [12] =&gt;
      [13] =&gt;
      [14] =&gt;
      [15] =&gt;
      [16] =&gt;
      [17] =&gt;
      [18] =&gt;
      [19] =&gt;
      [20] =&gt;
  )
  </code></pre>
  
  <p>These are ages, so how can I group these into age groups?</p>
  
  <p>Lets say I want the following age groups: <code>&lt;= 18</code> <code>19-26</code> <code>27-32</code> <code>&gt; 32</code></p>
  
  <p>It is supposed to look:</p>
  
  <pre><code>(
  [&lt;= 18] =&gt; 1
  [19-26] =&gt; 4
  [27-32] =&gt; 2
  [ &gt; 32] =&gt; 1
  )
  </code></pre>
  
  <p>Is there a ready function for this?</p>
  
  <p>My solution:
  1 tedious way would be to create variables of age groups. Than foreach and increase variable ++ for specific age group if key matches range <code>($min &lt;= $value) &amp;&amp; ($value &lt;= $max)</code>...</p>