|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
replace enter with
okay, with my forum, i need it to replace an enter (line break) with a <br>, cause when its outputted, it ignores it otherwise. Anyone know how this would be done?
regards |
|
#2
|
|||
|
|||
|
RE: replace enter with
Check out the nl2br function
|
|
#3
|
|||
|
|||
|
RE: replace enter with
Code:
$message = ereg_replace ( "rn", "<br>", $message); |
|
#4
|
|||
|
|||
|
RE: replace enter with
or:
$mystring = "some stringn"; $mybrline = preg_replace("/n/", "n<br>", $mystring); |
|
#5
|
|||
|
|||
|
RE: replace enter with
How about:
$replaced_string = str_replace(chr(13).chr(10), "<br>", $string); |
|
#6
|
|||
|
|||
|
RE: replace enter with
Actually you should do this:
$message = ereg_replace("(rn|n|r)", "<br>", $message); Because Macintosh uses "r", Unix uses "n", and Windows uses "rn". |
|
#7
|
|||
|
|||
|
RE: replace enter with
This is the easiest way.
$stuff = ereg_replace(13,"<br>",$stuff); |
|
#8
|
|||
|
|||
|
RE: replace enter with
Who said there's only one way to skin a cat?
|
|
#9
|
|||
|
|||
|
RE: replace enter with
Thats ok to skin cats Just, please... No Cows.
|
|
#10
|
|||
|
|||
|
RE: replace enter with
You can also reverse it. Say you are editing the lines they will display in the text box as <br> <br> so just reverse it as it comes in
$stuff = ereg_replace("<br>",13,$stuff); Then reverse it again when you write the edit it. PHP is proof that God loves us and wants us to be happy |
|
#11
|
|||
|
|||
|
RE: replace enter with
haha, jebus, so many things saying the same thing ;) i just used the nl2br() function, worked perfectly...
|
|
#12
|
|||
|
|||
|
RE: replace enter with
But there is not a function like br2nl only nl2br, so if you want to replace "<br>" with a carriage return you'll have to use ereg_replace
|
|
#13
|
|||
|
|||
|
RE: replace enter with
holy crap jorgen, your signature or something is totally rootin up this forum.,..lol, the whole bottom half of the page is marquee'ing..lol
|
|
#14
|
|||
|
|||
|
RE: replace enter with
haha, its fixed now
|
|
#15
|
|||
|
|||
|
RE: replace enter with
darn, i wana c the scrolling text!
cos it goes round and round and round and round and round and round, boy im feeling dizzy and sick now |
![]() |
| Viewing: Codewalkers Forums > PHP Related > PHP Coding > replace enter with |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|