I need to display a list of dates from a database. There can be multiple records with the same date,开发者_如何学编程 but I only want the date to display once.
In other words, I need to only display unique dates. Any ideas?
Have you tried using DISTINCT in your sql query?
You can build an array with the date as a key. And the results in tere.
$return = array();
foreach ($results as $result) {
$return[$result['data']][] = $result;
}
where $return is an array with unique dates as a key.
If your dates are formatted the same you could build an array directly and use array_unique().
http://us3.php.net/manual/en/function.array-unique.php
精彩评论