/    Sign up×
Community /Pin to ProfileBookmark

Hi, how do I strip ALL tags and leave only text?

when I try

[code=php]echo strip_tags($desc)[/code]

I still get the <div> and all the other tags??

I found this thread but wasn’t sure how to implement it or if it would even work:
[url]http://www.webdeveloper.com/forum/showthread.php?t=165278[/url]

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@NogDogJun 04.2008 — To the best of my knowledge, strip_tags() should have done the job. Do you have a specific example where it does not?
Copy linkTweet thisAlerts:
@72newbieauthorJun 04.2008 — [CODE]uploadgeek.com/uploads456/0/striptags.bmp[/CODE]

from my main page...
Copy linkTweet thisAlerts:
@NogDogJun 04.2008 — If that is what you are actually seeing in your browser, then it looks to me like the text has already been filtered by htmlspecialchars() or htmlentities(), so there are not any actual tags in that text. If you do a "view source" in your browser, is it actually html tags, or is it character entities, e.g.:
<i>
</i>&amp;lt;TABLE cellSpacing=0&amp;gt;

If it's character entities as I suspect, then you need to apply the strip_tags() [i][b]before[/b][/i] htmlspecialchars() or htmlentities() is applied to the text.
Copy linkTweet thisAlerts:
@72newbieauthorJun 04.2008 — I don't think I'm using either function you listed and it's only doing it with some listings...
×

Success!

Help @72newbie spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.4,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...