I'm trying to find count of duplicate values in result received from active record in codeigniter.

```
For example:

1 => 12
2 => 21
3 => 22
4 => 21
5 => 12
6 => 45

```

Is there a way we can find out total count so it comes out with 12 = 1, 21 = 2, 22 =1, 12 = 2, 45 = 1 etc?

Codeigniter way would be great but I am also open to PHP way. 

OK array\_count\_values does not work with below array:

```
Array
(
    [0] => Array
        (
            [key_id] => 1790
            [key_name] => printer brisbane
            [link_id] => 1130
            [link_url] => 99cards.com
        )

    [1] => Array
        (
            [key_id] => 1982
            [key_name] => test
            [link_id] => 1130
            [link_url] => 99cards.com
        )

)

```

Is there a way we can find out that link\_id count is 2?

I found answer myself. Below is the code:

```
$e = 0;
            foreach ($q as $qs){
                $i = 1;
                foreach ($q as $qss){
                    if($qss['link_id'] == $qs['link_id']){
                        $q[$e]['link_count'] = $i;
                    }
                    $i++;
                }
                $e++;
            }

```