Solved

strip_tags: replace all zapped tags with one space

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article discusses how to create an extensible mechanism for linked drop downs.
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
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 look for a specific file type in a local or remote server directory using PHP.

708 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now