Solved

html to regular text using php function

Posted on 2011-02-23
11
350 Views
Last Modified: 2012-05-11
convert

<br>
<p>hi how are you<p>
<b>bold</b>


into regular text

using a php function
0
Comment
Question by:rgb192
11 Comments
 
LVL 17

Expert Comment

by:Dushan De Silva
ID: 34966087
<?php
echo"<br>";
echo "<p>hi how are you<p>";
echo "<b>bold</b>";
?>
0
 
LVL 17

Expert Comment

by:Dushan De Silva
ID: 34966100
0
 
LVL 1

Expert Comment

by:DoCBReeD
ID: 34966131
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 17

Expert Comment

by:Dushan De Silva
ID: 34966145
0
 
LVL 17

Expert Comment

by:Dushan De Silva
ID: 34966158
Sorry earlier I miss understood the question, that you code to convert html2php , later I identified you want html2text.

http://sb2.info/php-script-html-plain-text-convert/
http://www.tipsntutorials.com/tips/PHP/41
0
 
LVL 11

Expert Comment

by:Ovid Burke
ID: 34966233
Try this:

<?php
$str_html = '<br>
<p>hi how are you<p>
<b>bold</b>';

echo strip_tags($str_html);
?>

Open in new window

0
 
LVL 4

Expert Comment

by:LAMASE
ID: 34966319
forever strip_tags() !
0
 
LVL 109

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 34969841
Some combination of strip_tags() and nl2br() will give you the results you probably want.  When you post a Q like this, it is helpful for us to see what you want.  Posting an example of the results would be a lot more helpful than saying "regular text" which is ambiguous and has no meaning in computer science.

Install this and run it.  Use view source to look at the created output.  One of the six possible solutions will probably be what you want.

Best regards, ~Ray
<?php // RAY_temp_rgb192.php
error_reporting(E_ALL);

// TEST DATA FROM THE POST AT EE
$str = <<<ENDSTRING
<br>
<p>hi how are you<p>
<b>bold</b>
ENDSTRING;

// SHOW SOME WAYS OF DISPLAYING THIS INFORMATION
echo "<pre>";
echo htmlentities($str);
echo "</pre>";

echo $str;

echo htmlentities($str);

echo strip_tags($str);

echo nl2br(strip_tags($str));

echo nl2br(strip_tags($str, '<br>'));

Open in new window

0
 

Author Closing Comment

by:rgb192
ID: 35031967
thanks
0
 

Author Comment

by:rgb192
ID: 35031989
I have a similar more complex question that involves entering any html into a database and the database being able to save muliptle lines without using html

http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_26852658.html
0
 

Author Comment

by:rgb192
ID: 35032254
Disregard previous


I want to do this with a more complex h1 tag

http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_26862770.html
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

809 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