[ create a new paste ] login | about

Link: http://codepad.org/W2DITRJS    [ raw code | output | fork ]

PHP, pasted on Aug 11:
1
2
3
4
5
6
7
8
<?php
echo "<pre>";
$str = "my name is yogesh, i am great yogesh, and i am great programmer too.";
$new_arr = array_filter(preg_split('/[,. ]/',$str));
$count = array_count_values($new_arr);
arsort($count);
$sliced = array_slice($count,0,5,true);
print_r($sliced);


Output:
1
2
3
4
5
6
7
8
<pre>Array
(
    [am] => 2
    [great] => 2
    [yogesh] => 2
    [i] => 2
    [programmer] => 1
)


Create a new paste based on this one


Comments: