Jump to content

Matching HTML tags and content


ionik

Recommended Posts

Hey i cant seem to find anything on this and lost the code i developed long ago for this and my memory isnt to good on it.

What I'm trying to do is make a 2 functions one will read text a user inputs and find if there are any opening html  tags and there atrr. If it finds html opening tags it will compare them to an array of html tags allowed to be used by the user and if not remove the unwanted tags leaving the text inside of them. And the other function will find closing html tags and compare them to the ones that are allready opened and get the text that is within the html tags and prepare it for output. Here is an example of what it would be.

$text = '<span color="red">This text is red</span> This text is outside html tags';
//it will take the code and make these variables
$opentags = 1;
$closetags = 1;
$parsetext = 'This text is outside html tags';
$parseabledata = 'This text is red';
$opentags = array('span color="red"');
$closetags = array('span');

Link to comment
https://forums.phpfreaks.com/topic/86935-matching-html-tags-and-content/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.