Pfft <?php function top10($s) { $a = array_count_values(preg_split('/\b\s+/', $s)); arsort($a); return array_slice($a, 0, 10); }
array_count_values(...)
arsort(...)
array_slice(...)
Thinking.. two of these things belong together, two of these things are kind of the same.. but one of these things is doing his own thing...Seriously built in method naming and argument ordering don't follow any consistent convention in PHP, that's always been the most irksome thing to me...