Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

strip_tags: replace all zapped tags with one space

Posted on 2009-05-20
2
Medium Priority
?
2,456 Views
Last Modified: 2012-05-07
I want all HTML tags to be replaced with a single space.  

strip_tags() does not dot this so words run togeather.
<?php
echo strip_tags('<p>experts</p><div><p>ex</p><p>change</p></div>');
?>

Open in new window

0
Comment
Question by:hankknight
2 Comments
 
LVL 3

Accepted Solution

by:
smueller72 earned 2000 total points
ID: 24435529
you can create a separate function for this that strips the tags out and replaces them with spaces. you will probably need to use a combination of str_replace('<p>', ' ', $string); tags for this to function correctly.
0
 
LVL 16

Author Comment

by:hankknight
ID: 24435676
smueller72, that is a good idea:
function striptags ($str) {
 return trim(strip_tags(str_replace('<', ' <', $str)));
}

Open in new window

0

Featured Post

Independent Software Vendors: 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!

Question has a verified solution.

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

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…
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 i…
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.
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 …
Suggested Courses

783 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