Help To Count Number and then Grouping The Result From Text Area

Hai …
I’m really newbie here, but i wish you could help me to create some PHP Script that could counting the number and then grouping the result by the number.
Ex:
in textarea i write this number 1228323991237412398012312381038210382180328103241283092183012803 and then when i klik the go button, the result is :
Numbers | Count
2 14
3 13
1 12
8 10
0 8
9 4
4 2
7 1

Thank’s you …

tally your results into an array using the number as the index, and the count as the value. Then sort the array by index(key) and then echo out each element of the array.
$nums = $_POST[‘mytextarea’]; // get the value from the textarea
$nums_ar = str_split($nums,1);
$results_ar = array();
foreach ($nums_ar as $val)
{
if (array_key_exists($results_ar[“$val”]))
$results_ar[“$val”]++;
else
$results_ar[“$val”] = 1;
}
ksort($results_ar)
foreach($results_ar as $k=>$v)
echo “$k occurred $v times<br>”;

I’d do it a -little- bit more streamlined, but same methodology!

$result = [FPHP]array_count_values/FPHP;
ksort($result);
foreach($result as $k=>$v)
echo “$k occurred $v times<br>”;

(Hooray for inbuilt functions!)