Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
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?
Add a comment
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().
https://www.php.net/manual/en/function.array-unique.php
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.