array_unique & multi-dimensional arrays
| From: | sasha | Date: | Mon, 19 Aug 2002 18:09:55 +0000 |
| Subject: | array_unique & multi-dimensional arrays | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-113244@lists.php.net to get a copy of this message | ||
I am trying to clean up some junky code in a journal/news type
script and redoing the archive navigation. I am pulling all of
the dates of the entries and pushing it into a multi-
dimensional array like so:
array_push($archive_nav, array(month => $month, year => $year,
longmonth => $longmonth));
I assumed I could just use array_unique to filter out all of
the duplicates in the array. But it doesn't seem to work that
way, and the only month/year combo I end up with is the very
oldest one (according to year/month) in the array.
$archive_nav = array_unique($archive_nav);
If I leave out array_unique, I am getting all of the
appropriate month/year combos in my script while doing a
foreach... just one for every single entry in the database for
that combo (which is a lot in some cases!).
Is there a better way to do this?
sasha