Jump to content

Searching for next event in a list


LLapsus

Recommended Posts

Hello, I am quite new in PHP.

 

I am doing a page with list of events (seminars).

The events are saved in a XML file in chronological order and their each event has its date in d-m-Y format and time in h:m format.

What I need to do is find the next event (with respect to the actual date and time).

I can do it using a loop (foreach) and stringtotime() and comparing obtained values. However, this seems to be quite a clumsy way.

Is there any better way to do it? Maybe there is a function, package or some extension, which I don't know...  :shrug:

 

I tried xpath, however it does not know how to compare the dates (I use xml 1.0).

 

Thank you very much.  :)

 

Link to comment
https://forums.phpfreaks.com/topic/249139-searching-for-next-event-in-a-list/
Share on other sites

The problem here is the xml file.  If it were a database, you would have date functions to help you pull only the valid info.  Being that it is xml, I don't know of a way for you  to check dates, other than looping the data, until you find the one that you want.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.