I have this Array :
Array (
[0] => Array ( [x] => 2016-04-19 )
[1] => Array ( [x] => 2016-05-25 )
[2] => Array ( [x] => 2016-05-26 )
[3] =&g
Using array_map you can convert the dates to strings, then you can use array_count_values
:
$theArray = array(array('x' => new DateTime('2016-04-19')),
array('x' => new DateTime('2016-04-19')),
array('x' => new DateTime('2016-04-19')),
array('x' => new DateTime('2016-05-19')));
function formatDate($d) {
return $d['x']->format('Y-m-d');
}
$results = array_map("formatDate", $theArray);
print_r(array_count_values($results));
.
Array (
[2016-04-19] => 3
[2016-05-19] => 1
)
Then you can use this to determine the duplicates.
(This would also be useful if the dates contained time elements that you wanted to ignore.)