Viper007Bond Posted November 20, 2003 Share Posted November 20, 2003 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: <li>$text_from_database</li> 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. Link to comment https://forums.phpfreaks.com/topic/1400-replace-line-breaks-with-perhaps-a-ph/ Share on other sites More sharing options...
triphis Posted November 20, 2003 Share Posted November 20, 2003 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) Link to comment https://forums.phpfreaks.com/topic/1400-replace-line-breaks-with-perhaps-a-ph/#findComment-4658 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.