Re: Count how many times a value occurs in an array [message #179264 is a reply to message #179263] |
Thu, 27 September 2012 07:10 |
aroniss
Messages: 1 Registered: September 2012
Karma:
|
Junior Member |
|
|
On Thursday, September 27, 2012 8:25:21 AM UTC+2, Ryan wrote:
> I have an array lets say for example:
>
>
>
> $my_array = array('1', '1', '2', '3', '1', '3', '2');
>
>
>
> I want a listing of each value in the array and how many times it occurs for in this case it would look like this
>
>
>
> array ('1' => 3, '2' => 2, '3' => 2)
>
>
>
> jw if ph has a build in function to make this easy of am I going to have to roll my own by looping though the array?
Use built-in function: array_count_values($my_array)
|
|
|