Dinamic array

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
gastoncs
Forum Newbie
Posts: 2
Joined: Tue May 12, 2009 8:00 pm

Dinamic array

Post by gastoncs »

Hi all, I want to create an array that can be generates dynamically, here is the example

I am going to loop this numbers

3
4
2
3
4
1
4

I dont know in advance how many numbers will be.

this is the result I want: $result=array(1=>1,2=>1,3=>2,4=>3)

I want to have the key and the count of each number.

Thanks in advance
gastoncs
Forum Newbie
Posts: 2
Joined: Tue May 12, 2009 8:00 pm

Re: Dinamic array

Post by gastoncs »

I just found out I can use this function : array_count_values($array);
Post Reply