Solved

html to regular text using php function

Posted on 2011-02-23
11
354 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
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…
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…

729 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