Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Srting function: how bring a comment with <br> or \n on one line

Posted on 2003-03-11
9
Medium Priority
?
179 Views
Last Modified: 2012-05-04
i got the following :

  $dat = "txt/txt.txt";
  $dat = fopen($dat,"a");
  $fcomment = strip_tags($fcomment);
  $fcomment = eregi_replace("\n","<br>", $fcomment);
  $fcomment = stripslashes($fcomment);
  $info = $ftopic."#".$fname."#".$fmail."#".$fcomment;
  fputs($dat,$info);
  fclose($dat);

the output looks like that:

new topic#reto#reto@mail.com#this
br>is my
br>first comment
****************************************************

so why does the line 4 in the script replace me an br> instead of a <br> and how can i get the requested output all in one line like this:

new topic#reto#reto@mail.com#this<br>is my<br>first comment


many thanks;)


0
Comment
Question by:malachay
  • 5
  • 2
  • 2
9 Comments
 
LVL 15

Expert Comment

by:VGR
ID: 8111064
first you have a nl2br() function in stead of silly-unmaintanable-unreliable eregi() calles like "$fcomment = eregi_replace("\n","<br>", $fcomment); "
(you also have str_replace() )

I ***guess*** that the first < should be escaped. I suggest you use SINGLE QUOTES like this :
$fcomment = eregi_replace('\n','<br>', $fcomment);
0
 

Author Comment

by:malachay
ID: 8111198
many thanks this might help.

but about the other thing. do you have an idea. (to bring the whole thing on one line)

thanks
0
 

Author Comment

by:malachay
ID: 8111257
many thanks this might help.

but about the other thing. do you have an idea. (to bring the whole thing on one line)

thanks
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 6

Accepted Solution

by:
carchitect earned 320 total points
ID: 8111330
replace \r\n with <br>
instead of \n
0
 

Author Comment

by:malachay
ID: 8111384
bingo
many many thanks.
0
 

Author Comment

by:malachay
ID: 8111391
so fast. excellent
0
 
LVL 15

Expert Comment

by:VGR
ID: 8111474
how did you "know" it was on Windows ? :D
0
 
LVL 6

Expert Comment

by:carchitect
ID: 8111925
Hi VGR how are you
Its so nice to see you.. here too
so whats up, and how is your answer session going ...
i hope its good..
0
 

Author Comment

by:malachay
ID: 8112295
;) i love windows (?) :0
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to create an extensible mechanism for linked drop downs.
It’s a season to be thankful, and we’re thankful for users like you who engage on site, solve technology problems, and network with others in the industry. What tech are we most thankful for? Keep reading.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question