0

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?

3 Answers 3

1

Have you tried using DISTINCT in your sql query?

Sign up to request clarification or add additional context in comments.

1 Comment

This would have been perfect, but I forgot to mention that they're unix timestamps. Thank you so much!
0

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.

Comments

0

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

Comments

Your Answer

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.

Ask question

Explore related questions

See similar questions with these tags.