This is a discussion on Displaying & formatting text with mysql database within the PHP Language forums, part of the PHP Programming Forums category; I need some help with formatting some text received from a database query. I am only selecting a single row ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
I need some help with formatting some text received from a database
query. I am only selecting a single row per query so the formatting will only be performed on a single row. The rows I need to format upon display to the user are currently in text like so: word1 word2 word3 word4 (note there are only spaces between each word) I just want to insert a character between each word when displayed. A dash, for example. I want it to look like this: word1 - word2 - word3 - word4 etc. Its too late to do it b4 I put it in the database, so I have to do it now. Any ideas? TIA Rob |
|
|||
|
On 7-Oct-2003, gojuka@si.rr.com (Robert) wrote: > I need some help with formatting some text received from a database > query. I am only selecting a single row per query so the formatting > will only be performed on a single row. The rows I need to format > upon display to the user are currently in text like so: word1 word2 > word3 word4 (note there are only spaces between each word) > > I just want to insert a character between each word when displayed. A > dash, for example. I want it to look like this: word1 - word2 - word3 > - word4 etc. Its too late to do it b4 I put it in the database, so I > have to do it now. Any ideas? I'm not totally clear on the question but try this: // assuming $row has been retrieved from the database $fieldwithdashes = str_replace(' ',' - ',$row['fieldname']); echo $fieldwithdashes; -- Tom Thackrey www.creative-light.com tom (at) creative (dash) light (dot) com do NOT send email to jamesbutler@willglen.net (it's reserved for spammers) |
|
|||
|
"Tom Thackrey" <use.signature@nospam.com> schrieb:
> // assuming $row has been retrieved from the database > $fieldwithdashes = str_replace(' ',' - ',$row['fieldname']); I just wanted to post something with regular expressions. Glad you were first. :-) Regards, Matthias |