Solved

strip_tags: replace all zapped tags with one space

Posted on 2009-05-20
2
2,331 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

Are You Using the Best Web Development Editor?

The worlds of web hosting and web development are constantly evolving. Every year we see design trends change, coding standards adapt and new frameworks/CMS created. With such a quick pace of change it’s easy to get lost trying to keep up.

See if your editor made the list.

Question has a verified solution.

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

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
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…
The viewer will learn how to count occurrences of each item in an array.

623 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