View Full Version : Question on merging multi-dimensional arrays

Daniel Israel
03-25-2010, 09:23 PM
I have 2 arrays. They both represent data returned from a database query. Each array item is an array (row of data in the database).

What I'd like to do is to merge the arrays, but to remove duplicate IDs (which is not the array index...)

I know.... Why?

I'm keeping a calendar. I want to list the next X items in the calendar. The first array is a list of recurring events (every Tuesday, every 15th of the month, etc...) and the second list is the one-time events. The catch is that a one-time event can over-ride an instance of a recurring event. (For example, if I have a class every Tuesday night, I set that as a recurring event. I can then enter a one time event (say, going to my niece's play) and when I list the events, the play comes up instead of the class for that evening...)

Right now, what I'm doing is going through the array items one by one and checking the values, then replacing them. Is there an easier way to do this?


03-25-2010, 09:33 PM
This sounds like a job for SQL.
I assume its coming from the same table yeah? How do you determine recurrance, just with the use of a flag / field for it?

Old Pedant
03-26-2010, 03:38 AM
Assuming all these events are in the same table, I certainly would tend to agree with FouLu.

But without seeing you DB schema, we can't be sure. I think it depends a lot on how you define recurring events in the DB.

Daniel Israel
03-29-2010, 05:28 PM
They're not coming from the same table, but it's sounding more and more like that's the way to go. Since I'd have to redo the schema anyways, any suggestions on how to set it up (in particular, what would I need to do to have a query do that work?)