fork download
  1. <?php
  2. $array = array(5,5,10,20,30,40,50,64,7,10);
  3. $a = array_fill(0, 9, 0);
  4. foreach ($array as $number)
  5. $a[(int)($number/10)]++;
  6. print_r($a);
Success #stdin #stdout 0.02s 24324KB
stdin
Standard input is empty
stdout
Array
(
    [0] => 3
    [1] => 2
    [2] => 1
    [3] => 1
    [4] => 1
    [5] => 1
    [6] => 1
    [7] => 0
    [8] => 0
)