PHP Array_Unique Problem

rariboors

New Member
I don't know PHP very well, so please bear with me.My client has a database with information and one of the fields is ff_date_time in the format "Tue Oct 5 14:43:10 2010". There are a lot of entries in here and I need to display a list of just the days that have entries: ie,
  • Tue Oct 5, 2010
  • Thurs Oct 7, 2010
and so on. There may be hundreds of entries on a certain day, so obviously when I pull in dates from the db I need to go through and extract the right data and filter it. Here's what I have so far:\[code\]$query = "SELECT ff_date_time FROM booth_submit"; $query_result = mysql_query($query);$datetimes = array();$dates = array();while ($row = mysql_fetch_array($query_result)) { $datetimes[] = $row['ff_date_time'];}for ($i = 0; $i < sizeOf($datetimes); $i++) { $temp = explode(" ", $datetimes[$i]); $dates[] = ($temp[0]." ".$temp[1]." ".$temp[2]." ".$temp[4]); # Breaks date_time into 'Mon Oct 5 2010' format}$dates = array_unique($dates); for ($i = 0; $i < sizeOf($dates); $i++) { echo('<a href="http://stackoverflow.com/questions/3883272/#">'.$dates[$i].'</a><br />'); }\[/code\]I'm doing a similar thing for two others fields that work fine, but for some reason, this always yields a $dates array that is the right length (ie: 4 unique dates, array is size 4), but only the first $dates element has any info. The output looks like this:\[code\]<a href="http://stackoverflow.com/questions/3883272/#">Mon Oct 3 2010</a><br /><a href="http://stackoverflow.com/questions/3883272/#"></a><br /><a href="http://stackoverflow.com/questions/3883272/#"></a><br /><a href="http://stackoverflow.com/questions/3883272/#"></a><br />\[/code\]When I don't use array_unique and just test values to check if everything is getting loaded and parsed correctly, the array is just as it should be ("Mon Oct 3 2010","Mon Oct 3 2010","Mon Oct 3 2010","Mon Oct 4 2010","Mon Oct 5 2010","Mon Oct 5 2010","Mon Oct 6 2010").Any clues what's going wrong here?
 
Back
Top