Solved

html to regular text using php function

Posted on 2011-02-23
11
347 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:Dushan911
ID: 34966087
<?php
echo"<br>";
echo "<p>hi how are you<p>";
echo "<b>bold</b>";
?>
0
 
LVL 17

Expert Comment

by:Dushan911
ID: 34966100
0
 
LVL 1

Expert Comment

by:DoCBReeD
ID: 34966131
0
 
LVL 17

Expert Comment

by:Dushan911
ID: 34966145
0
 
LVL 17

Expert Comment

by:Dushan911
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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 108

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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 …

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now