I am looking for a way to remove some characters from the end of a field in my MySql database.
Say I have a table called ‘items’ and there is a field called ‘descriptions’, some of those descriptions have <br>’s at the end. There could be a single case, or there could be 2-3 <br>’s at the end of that field.
I need to find a way through PHP/MySql to trim off these <br>’s. There may be other <br>’s in the description that I want to keep, it is just the ones at the end I need removed.
I know I can loop through every entry, check for that tag at the end, if it exists strip it off, and then update the DB with the new value. But this seems like the long way of doing it, and I’m not sure how to best achieve what I am trying to do.
I don’t have a mysql instance to test, but something like this would probably do it:
Take a look at some of the string functions.