Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

php: new line

Posted on 2004-08-10
6
Medium Priority
?
177 Views
Last Modified: 2008-03-06
This code is located on the confirm page which is fine but the next page is the reply.php page and the output of this is outputed in a email form and when it display the values, it's showing the tags "<br>".
How can i not show the tags but i still need the new line or break.
this is the code i'm using:
*********************
 <TD width="300" wrap="PHYSICAL" bgcolor="#eeeeee">
<?
    $equipmentlist = stripslashes($equipmentlist);
    $equipmentlist = htmlspecialchars($equipmentlist);
    $equipmentlist = nl2br($equipmentlist);
    echo $equipmentlist;
?>
</td>
*****************************
this is the output as you can see the "<br> tags"
*******************************
asdf asdf asdf asdf asdf asdf <br />
<br />
asdf asdf
****************
0
Comment
Question by:imaw
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 5

Expert Comment

by:TheClickMaster
ID: 11766397
You could try to replace all the <br /> with \n before displaying it on the reply.php page

str_replace("\n", "<br />",  $equipmentlist);
0
 
LVL 5

Accepted Solution

by:
TheClickMaster earned 2000 total points
ID: 11766407
Oups, wrong order...

str_replace("<br />", "\n", $equipmentlist);
0
 

Author Comment

by:imaw
ID: 11766473
on the reply page, it is spitting out html i think so i'm not sure how. where do i put this code?
this is what i have on reply.php page:
**************************
$mailbody .= "IS Equipment which Requires Moving:" ."\n" . $equipmentlist . "\n";
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 36

Expert Comment

by:Zyloch
ID: 11766549
Hi

Just make sure you put the code before you echo $equipmentlist.

By the way, are you echoing $mailbody or $equipmentlist?

Regards,
Zyloch
0
 

Author Comment

by:imaw
ID: 11766575
This did the trick:
 echo nl2br(htmlspecialchars(stripslashes($comments)));

this keeps it pure.
0
 
LVL 5

Expert Comment

by:TheClickMaster
ID: 11768197
pure is good :)
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

610 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