Manipulating arrays and mySQL query results
Posted: Tue Feb 07, 2006 6:53 pm
I need to fetch the contents (text stings) of a mySQL database table, stripping the tags from each text string, and putting them in order of descending length.
For example, if my database contains:
XXXXX
<b>YYYY</b>
ZZZZZZZZZ
Then I would get this array:
ZZZZZZZZZ
XXXXX
YYYY
The code I'm using now includes the length bit in the mySQL query ("ORDER BY LENGTH(whatever) DESC"), and then strips the tags, but I need this to happen the other way around so that the length calculation doesn't include the tags!
I'm hoping there is some way to basically do "ORDER BY LENGTH(strip_tags(whatever)) DESC" in the mySQL query, because otherwise I have to actually deal with manipulating/rearranging the array, and that's way out of my experience.
Any help is much appreciated!
For example, if my database contains:
XXXXX
<b>YYYY</b>
ZZZZZZZZZ
Then I would get this array:
ZZZZZZZZZ
XXXXX
YYYY
The code I'm using now includes the length bit in the mySQL query ("ORDER BY LENGTH(whatever) DESC"), and then strips the tags, but I need this to happen the other way around so that the length calculation doesn't include the tags!
I'm hoping there is some way to basically do "ORDER BY LENGTH(strip_tags(whatever)) DESC" in the mySQL query, because otherwise I have to actually deal with manipulating/rearranging the array, and that's way out of my experience.
Any help is much appreciated!