Jump to content

[SOLVED] removing text between two characters in a string


sasquatch69

Recommended Posts

I searched for this on the forums but did not find an answer to my question, so here goes:

 

I am trying to find a way to strip out everything between two characters in a string. 

 

The php script will be pulling text from a separate html file that automatically updates itself with new content on an hourly basis (designed to pull into string $rawtext via file_get_contents).  One of the information fields in the file (which are separated by HTML tables, which I am using str_replace to change into divs for standards compliance) contains the start and end time of an event, and pulls into a div class of its own on my page in a hh:mm am/pm to hh:mm am/pm format (e.g. "10:00am - 11:00am" or "12:00pm - 1:00pm").  I only want to display the beginning time without the hyphen and the ending time, so that it just reads "10:00am", but I have no access to change how the file is output (here is the code chunk: "<TD>12:00PM - 2:00PM</TD>").

 

From what I can tell, I can't use str_replace because that end time will be constantly changing.  And I can't truncate how much text is pulled in from the file because there are other fields after the time in the file that I will need.  So, is there a better way to strip the "- hh:mmtt" from the middle of the file?

Link to comment
Share on other sites

Sorry, I didn't do a great job of explaining.

 

The times will change every hour to reflect the current hour (and the hour immediately following), which is why I can't just put a certain time down and then use a function to replace it.  I just used the 12:00pm - 2:00pm as an example.

 

Thus, I am trying to find a way to strip out everything from the hyphen until the </TD>, regardless of what time it says.

 

Thanks!

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.