arrays - PHP Array_Unique Problem -
i don't know php well, please bear me.
my client has database information , 1 of fields ff_date_time in format "tue oct 5 14:43:10 2010". there lot of entries in here , need display list of days have entries: ie,
- tue oct 5, 2010
- thurs oct 7, 2010
$query = "select ff_date_time booth_submit"; $query_result = mysql_query($query); $datetimes = array(); $dates = array(); while ($row = mysql_fetch_array($query_result)) { $datetimes[] = $row['ff_date_time']; } ($i = 0; $i < sizeof($datetimes); $i++) { $temp = explode(" ", $datetimes[$i]); $dates[] = ($temp[0]." ".$temp[1]." ".$temp[2]." ".$temp[4]); # breaks date_time 'mon oct 5 2010' format } $dates = array_unique($dates); ($i = 0; $i < sizeof($dates); $i++) { echo('<a href="#">'.$dates[$i].'</a><br />'); }
i'm doing similar thing 2 others fields work fine, reason, yields $dates array right length (ie: 4 unique dates, array size 4), first $dates element has info. output looks this:
<a href="#">mon oct 3 2010</a><br /> <a href="#"></a><br /> <a href="#"></a><br /> <a href="#"></a><br />
when don't use array_unique , test values check if getting loaded , parsed correctly, array should ("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?
assign unique array array variable. , use foreach
.
$newarr = array(); $newarr = array_unique($dates); foreach ($newarr $date) { echo('<a href="#">'.$date.'</a><br />' . "\n"); }
Comments
Post a Comment