Jump to content


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

  • Please log in to reply
1 reply to this topic

#1 Viper007Bond

  • New Members
  • Pip
  • Newbie
  • 8 posts
  • LocationPortland, Oregon, USA

Posted 20 November 2003 - 10:47 AM

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. :)
- Viper007Bond

#2 triphis

  • Members
  • PipPipPip
  • Advanced Member
  • 62 posts

Posted 20 November 2003 - 09:38 PM

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
Xac Attack

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users