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