Well basically, I have a multidimentional array that I want to count state
, but sometimes in the array I can get duplicate lid
, so I got to get the lid
with the newest date_add
[0] => Array
(
[lhid] => 181
[lid] => 183
[uid] => 1
[state] => 2
[date_add] => 2012-12-06 09:25:41
)
[1] => Array
(
[lhid] => 198
[lid] => 203
[uid] => 1
[state] => 1
[date_add] => 2012-12-10 13:19:26
)
[2] => Array
(
[lhid] => 222
[lid] => 203
[uid] => 1
[state] => 1
[date_add] => 2012-12-13 20:12:06
)
Any way i can do this? Much appreciated!
Here's what have I tried so far and didn't succeed since it getr all the values :
$count = array();
foreach($stats_results as $state)
{
@$count[$state['state']]++;
}
Here's the wanted format :
Array
(
[1] => 110
[2] => 4
[0] => 4
[3] => 2
)