I am trying to count the duplicate keys from array $new_result_months
, remove them and update the value of $new_result_users
with the matching key. if I would do an array_combine
every key should match the value. I really tried but did not managed to think of a version.
$new_result_months = array(
'Dec 2013',
'Jan 2014',
'Feb 2014',
'Mar 2014',
'Apr 2014',
'May 2014',
'Jun 2014',
'Jul 2014',
'Aug 2014',
'Sep 2014',
'Oct 2014',
'Oct 2014', // remove one duplicate key and keep unique one
'Nov 2014',
'Nov 2014', // remove one duplicate key and keep unique one
'Nov 2014', // remove one duplicate key and keep unique one
'Dec 2014'
);
$new_result_users = array(
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
1,
1,
0
);
EXPECTED OUTPUT
$new_result_months = array(
'Dec 2013',
'Jan 2014',
'Feb 2014',
'Mar 2014',
'Apr 2014',
'May 2014',
'Jun 2014',
'Jul 2014',
'Aug 2014',
'Sep 2014',
'Oct 2014',
'Nov 2014',
'Dec 2014'
);
$new_result_users = array(
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1, // needs to match with month oct 2014 and update it to 1
2, // needs to match with month nov 2014 and update it to 2
0
);