I have an associative array with the key of date, and a value of teams. For instance:
- March 21, 2016 10:05 => 'Detroit vs. Philly'
- March 21, 2016 7:05 =>'Toronto vs. Ottawa'
- March 21, 2016 7:05 => 'Anahiem vs. Boston'
- March 21, 2016 10:25 => 'Chicago vs. Winnipeg'
The problem is the RSS feed that I am parsing does not give me this data in an ordered fashion. So I need to order these games by the date, and when I add these fields in an associative array, duplicate dates (you can see that two games start at 7:05 on March 21st) are omitted because two keys can not be the same. I have tried to reverse the data, so that the key is the value and the value is the key and I can sort it this way, but when flip the array back, (array_flip($input);) the same problem occurs because again two keys cannot be the same.
I'm sure there is a simple way to handle this, but I'm going around in circles.
Any help would be very much appreciated.
<?php
foreach ($feed->get_items() as $item): // this is my feed parser
$string = $item->get_title(); // gets each element
preg_match_all('/\((.*?)\)/', $string, $out);
$timedate = ($out[1][2]);
$array[$timedate] = $string; // creates an array with date as key, string data as values
endforeach;
?>
March 21, 2016 7:05occurs twiceusort()for this. Using keys for this makes no sense.