Solved

html to regular text using php function

Posted on 2011-02-23
11
351 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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

These days socially coordinated efforts have turned into a critical requirement for enterprises.
This article discusses four methods for overlaying images in a container on a web page
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 create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

830 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