Jump to content


This topic is now archived and is closed to further replies.


Replace line breaks with </li><li> (perhaps a PH

Recommended Posts

Okay, I want to enter into a box some lines that will be stored in one cell. Anyway, when I press \"enter\" and make a new line in the box, I want those line breaks to be replaced with \"</li><li>\" so that I can do:



and it\'ll make a list.


Should I do this through some PHP method or should I have it enter it into the table and then run a SQL REPLACE command and replace... whatever line break is with </li><li>?


Explain to me how to do what you suggest please. Thanks a bunch. :)

Share this post

Link to post
Share on other sites

Hmmm, interesting. Well, I have not tried this using line breaks, but I have with other symbols. What you need is the str_replace function. It will replace the specified symbol/space/whatever with whatever you choose.


On the porcess PHP page (the one where you INSERT the information), run the variable (which holds all the info that you entered) through this:


$replace = str_replace("/n", "</li><li>", "$string");


Where $string is the information. I am totally not sure if it will accept the /n as a line break :S If any errors popup, change that to || or some other obscure symbol, and use symbols to define the </li><li>


Oh yeah, and enter the $replace variable into the database, and not the old $string (or WHATEVER) :P

Share this post

Link to post
Share on other sites


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.