Comparing strings that contain html
Moderator: General Moderators
- SmokyBarnable
- Forum Contributor
- Posts: 105
- Joined: Wed Nov 01, 2006 5:44 pm
Comparing strings that contain html
I have two strings that contain html. One string is the initial unchanged string and the other string is the same string after it has been inserted in a wysiwyg editor (FCKeditor) and posted in a form. Basically I'm trying to compare the two strings to see if any changes were made. However when no changes are made I notice that the two strings are not equal. I assume this is because the editor alters the html somehow when posting the contents...even though no changes were made. So my question is how can I take two strings that contain html and strip them both down to check if they are equal or not?
- SmokyBarnable
- Forum Contributor
- Posts: 105
- Joined: Wed Nov 01, 2006 5:44 pm
I tried strip tags along with trim and when using to compare the two strings it only says they are 85% similar even though they look identical when I echo them out in browser?
Code: Select all
similar_text()- SmokyBarnable
- Forum Contributor
- Posts: 105
- Joined: Wed Nov 01, 2006 5:44 pm
Ok I added these statements and now I can tell if any edits were made to the string by comparing it to the original.
This is good but what if the person doesn't change any text in the editor but does make an html change like a background or font?
Code: Select all
$text = strip_tags($_POST['FCKeditor1']);
$text = stripcslashes($text);
$text = ereg_replace("[^A-Za-z0-9]", "", $text);
$text=str_replace("nbsp","",$text);