Solved

strip_tags: replace all zapped tags with one space

Posted on 2009-05-20
2
2,270 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
[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
2 Comments
 
LVL 3

Accepted Solution

by:
smueller72 earned 500 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
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…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

738 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