Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

strip_tags: replace all zapped tags with one space

Posted on 2009-05-20
2
Medium Priority
?
2,401 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 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
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 look for a specific file type in a local or remote server directory using PHP.

718 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