array order or unique

admin

Administrator
Staff member
ok here is one for the masses. say I have an array like so

$string = array(1,2,3,3,4,5,5,3);

so what I want is to get the unique numbers but at the same time count how many of the uniques there are.

so it would end up like this


$string = array(1=> 1,1=> 2,3=> 3,1=> 4,2=> 5);

understand? I am not sure array_unique will do this and I just can't seem to think at the moment.<?php
$string = array(1,2,3,3,4,5,5,3);
$result = array_count_values($string);
print_r($result);
?>see I looked at that for a couple hours and skipped over it everytime. :D thanks mate
 
Back
Top