Solved

html to regular text using php function

Posted on 2011-02-23
11
356 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
[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
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
Industry Leaders: 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 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 110

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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

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.
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The viewer will learn how to dynamically set the form action using jQuery.
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.

636 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