Hi there,
I want to apply the striptags() function selectively on <a> tags containing some specific pattern in the URL.
e.g. I have text that contains two different sorts of <a> tags:
sort 1:
<a href=/dirname1/somepage>something</a>
sort 2:
<a href=/dirname2/somepage>something</a>
note that "somepage" and "something" can vary from tag to tag. the different URL sorts can be distinguished by dirname1 or dirname2.
now, I want to scan the text and remove all <a> tags pointing to URLs that begin with /dirname1, while I want to keep all other tags.
after removal of sort 1 tags, only the anchors "something" should be left over.
how could this be done?
thanks for your help.
-saudepp
Apply striptags() selectively on <a> tags
Moderator: General Moderators
Re: Apply striptags() selectively on <a> tags
nobody has a clue?
please help ...
please help ...
Re: Apply striptags() selectively on <a> tags
strip_tags() does allow you to specify a whitelist of allowed tags. If you only want to strip links, you need to specify every tag except the <a> tag.[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1 wrote:4. All users of any level are restricted to bumping (as defined here) any given thread within twenty-four (24) hours of its last post. Non-trivial posts are not considered bumping. A bump post found in violation will be deleted, and you may or may not receive a warning. Persons bumping excessively be considered as spammers and dealt with accordingly.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Re: Apply striptags() selectively on <a> tags
please read my question carefully, it's not as simple as that ...
<a> shall be removed conditional on the URL structure.
some <a> tags should survive, some other <a> tags shouldn't.
<a> shall be removed conditional on the URL structure.
some <a> tags should survive, some other <a> tags shouldn't.
Re: Apply striptags() selectively on <a> tags
use preg_replacesaudepp wrote:please read my question carefully, it's not as simple as that ...
<a> shall be removed conditional on the URL structure.
some <a> tags should survive, some other <a> tags shouldn't.
Re: Apply striptags() selectively on <a> tags
thanks, I am already playing with preg_replace and regular expressions.
nice, but not so easy to learn ...
cheers
I wann use it on this page: Wellnessoase
nice, but not so easy to learn ...
cheers
I wann use it on this page: Wellnessoase