I have an array that looks like this:

```
$recs = array(1,4,7,1,5,4,1,12,1,4,6,5);

```

I want to get the most frequent item followed by the next most frequent item until I get to the least frequent item and then create another array with this information that looks like this:

```
$frequencies=array("1"=>4,"4"=>3,"5"=>2,"6"=>1,"7"=>1)

```

How can I achieve this, please help.