Jump to content

Recommended Posts

Okay, i wasnt sure what section to post in but im leaning toward this one so here it is. I am trying to find the most efficient way to remove not all HTML but some, strip_tags lets you define allowable tags, i need to only remove certain ones, the problem is if i have <-- or << then strip_tags removes them with the rest of the HTML, Is there a way to only take tags that were opened and closed? Or in other words valid HTML? Or would i have to create a regex for every common HTML tag to have it stripped on its own? I'm new to PHP so the only work around ive been able to use is to str_replace every group of characters into a number, then strip_tags, then the number back into the associated characters... i realize this is a rigged work around and thats why im looking for something more efficient especially since any undefined groups get pulled.

 

One option which im not even sure is possible would be to match any HTML and if its a letter following the bracket have it stripped the only exception would be to also taking out / in closing brackets, this way <a herf would be stripped <b> </b> would both be stripped, so if the bracket is followed by any non A-Z character besides / it will be stripped, but if any bracket is followed by another bracket or various other symbols that arent used it will be left alone.

Link to comment
https://forums.phpfreaks.com/topic/232926-help-with-either-regex-or-striptags/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.