Jump to content

htmlentites remove


The Little Guy

Recommended Posts

as I am have been thinking, I think I would like to keep some of the entities. I would like to remove all of the entities that would be useless if you were to do a search, on the database, such as: quot, copy, apos, etc.

 

I would like to keep amp and any other commonly searched for decoded entities.

 

If the purpose of this is for a search, why can't you just decode the entities when you're comparing against the database?

Link to comment
Share on other sites

I think the "Keep" list would be shorter, So...

 

not sure how I would do that...

 

well, for instance, you can do something like this:

 

$keepers = array('(amp)','(bar)');
$string = "&foo; something blah & blah &bar; something &blah;";
$keep = implode ("|",$keepers);
$string = preg_replace("~&(?!".$keep.")[^;]*;~","",$string);

 

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.