In php,I have one ArrayList. Lets say
$list = {1000,7000,5000,1000,6000,5000,1000,2000};
So what I want to do is that Make count of each element in list:
For example as above ,
1000 comes three times then count of 1000 = 3 5000 comes two times then count of 5000 = 2,etc.
And I want to access that count of different elements separately
.
Edit:
Here I have for loop
for($i=0;$i<count($trip);$i++)
{
// Here list will be new everytime for loop run.
$list = $Users->Matches($trip[$i]);
}
// ----------------------------------------------------------------------
Here what I want to do is that "Take all the element of list for value of
$i : 0 to count($trip)" and "add it into another list lets say $allList
and access" as below :
// -----------------------------------------------------------------------
$cnt_arr = array_count_values($allList);
foreach($cnt_arr as $key => $value) {
echo "\n\n Count of ".$key." = ".$value." ";
}
OUTPUT :
Lets say for loop runs first time :
$list = {1000,7000,5000}
Now for loop second time :
$list = {8000,1000,9000}
Now for loop is completed and at the end I want the $allList value as below :
$allList = {1000,7000,5000,8000,1000,9000}(which has all the elements of above-appended list)
So How can I do this ?
Please Guide me. Any help will be appreciated.
"; It is printing like this Count of 0 = 1000
– Ponting Aug 31 '13 at 11:57