Forum Moderators: coopster

Message Too Old, No Replies

Multiple values in one column

         

MarcoPolo

5:00 am on Mar 27, 2005 (gmt 0)

10+ Year Member


Is there some built in feature to PHP that will extract the contents of a field, let me manipulate it, then output it?

For example, let's say I have a field named 'sports' and in that one field I have 1 value. (Yes, it consists of 4 items, but it's just one value. Each item is separated by commas.)

sports: "football, baseball, soccer, golf"

How can I replace the commas with the HTML <br> tag when outputting the information to a web form?

Thanks,
David

Josefu

7:00 am on Mar 27, 2005 (gmt 0)

10+ Year Member



it's very simple, you would do a "str_replace()"

$my_text_with_br=str_replace(",","<br />",$my_text_with_commas);

...you can find all this in the php online documentation - it's quite extensive and well-explained.

www.php.net

coopster

3:00 pm on Mar 27, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



And welcome to WebmasterWorld, MarcoPolo.

MarcoPolo

4:41 pm on Mar 27, 2005 (gmt 0)

10+ Year Member



Thanks for the quick response.

I actually spent some time looking through the documentation and found this same thing on my own.

But now that I know how quickly I can get a response here, I may just use you guys!

HAHAHA!

Ok, just a joke.

But I do appreciate the response!

David