Solved

php: new line

Posted on 2004-08-10
6
174 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 500 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
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

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!

Question has a verified solution.

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

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
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.

732 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