HTML Tag to Characters Conversion

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
devarishi
Forum Contributor
Posts: 101
Joined: Fri Feb 05, 2010 7:15 pm

HTML Tag to Characters Conversion

Post by devarishi »

Hi,

In my web page there is a variable that contains HTML Tags as shown here:

Code: Select all

$msgBody = "<pre>Media ID\t\tLibrary Name</pre>"; 
$msgBody .= "<pre>--------------------------</pre>"; 
[b]---TRUNCATED---[/b]
The value of the variable is being written to a Text File and the output (the contents of the text file) also shows up the HTML Tags:

Code: Select all

 
<pre>Media ID       Library Name</pre><pre>--------------------------</pre><pre>123456          Goose</pre><pre>789651          Goose</pre>
So, how to convert HTML Tags before writing the variable's value to the text file? I think there is a function in PHP that serves this purpose.

Any ideas?




Note: http://corz.org/machine/source/php/tag-tools.php

Check out: Strip HTML Tags... button it does the work.
devarishi
Forum Contributor
Posts: 101
Joined: Fri Feb 05, 2010 7:15 pm

Re: HTML Tag to Characters Conversion

Post by devarishi »

User avatar
McInfo
DevNet Resident
Posts: 1532
Joined: Wed Apr 01, 2009 1:31 pm

Re: HTML Tag to Characters Conversion

Post by McInfo »

Why are there multiple sets of <pre> tags? Why not use "\n"?

Can you create the string without tags, write it to the file, then add the tags?

Edit: This post was recovered from search engine cache.
Post Reply