As you can see from the following array, there are three elements that appear on Nov 18, and another two elements that appear on Nov 22. Can someone tell me how I can retri
Here is my recursive variant:
$arr = array(
'0' => array(
'0' => array('2011-11-18 00:00:00' => 'C'),
'1' => array('2011-11-18 00:00:00' => 'I'),
'2' => array('2011-11-18 00:00:00' => 'S')
),
'1' => array(
'0' => array('2011-11-22 00:00:00' => 'C'),
'1' => array('2011-11-22 00:00:00' => 'S')
),
'2' => array(
'0' => array(
'0' => array('2011-11-22 00:00:00' => 'D')
)
)
);
function count_values($array, &$result = array(), $counter = 0)
{
foreach ($array as $key => $data)
{
if (is_array($data))
{
count_values($data, $result, $counter);
}
else
{
array_key_exists($key, $result) ? $result[$key]++ : $result[$key] = 1;
}
}
return $result;
}
print_r(count_values($arr));
This will return:
Array ( [2011-11-18 00:00:00] => 3 [2011-11-22 00:00:00] => 3 )