Jump to content


Photo

replace <br>


  • Please log in to reply
6 replies to this topic

#1 Gruzin

Gruzin
  • Members
  • PipPipPip
  • Advanced Member
  • 448 posts
  • LocationGeorgia

Posted 09 September 2006 - 02:07 PM

hi guys,
I geting data from db and I don't want to display <br>, </br> etc... I've tryed php.net and phpfreaks, here is my effort, but think I am not on the right way. Thanks in advance.

$txt = preg_replace( "<br />", "/\n/", $txt ); 
$txt = preg_replace( "<br>", "/\n/", $txt );
echo $txt;

I don't need your script, I'll try to write it myself

#2 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 09 September 2006 - 02:16 PM

This should do:
$txt = str_replace(array("<br />", "<br>"), "\n", $text);


#3 Gruzin

Gruzin
  • Members
  • PipPipPip
  • Advanced Member
  • 448 posts
  • LocationGeorgia

Posted 09 September 2006 - 02:21 PM

This should do:

$txt = str_replace(array("<br />", "<br>"), "\n", $text);

Tnak u very much, br is not any longer displayed, but still there is an empty line (br) between the text lines, any ideas what should I add that code?
I don't need your script, I'll try to write it myself

#4 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 09 September 2006 - 02:25 PM

This should replace them with nothing. Is that what you want?
$txt = str_replace(array("<br />", "<br>"), "", $text);
Legend has it that reading the manual never killed anyone.
My site

#5 Gruzin

Gruzin
  • Members
  • PipPipPip
  • Advanced Member
  • 448 posts
  • LocationGeorgia

Posted 09 September 2006 - 02:32 PM

$txt = str_replace(array("<br />","
", "
"), "", $text);
echo $txt;
this works for me. Thanks andy :) think u guys have helped me for 100000... times, really learning something!
I don't need your script, I'll try to write it myself

#6 newb

newb
  • Members
  • PipPipPip
  • Advanced Member
  • 454 posts

Posted 09 September 2006 - 05:33 PM

whats \n ?

#7 coldkill

coldkill
  • Members
  • PipPipPip
  • Advanced Member
  • 159 posts
  • LocationUnited Kingdom

Posted 09 September 2006 - 05:43 PM

It means newline.


You can learn alot from reading the manual




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users