Problem using similar_text with apostrophes

My code checks two variables to see if there are any changes. This works great with similar_text, except when it comes across a string containing an apostrophe. So then I used addslashes() prior to checking the code, to see if that would escape the apostrophe and allow similar_text to work. However, it still only checks up to the apostrophe and then stop. What more should I be doing?

Thank you!

In what way does it no longer “work great”?

I’ve never used similar_text so I’m not really sure why an apostrophe would have special meaning but you could always remove the apostrophes from the strings you’re comparing:

similar_text(str_replace('\'', '', $str1), str_replace('\'', '', $str2));

Thanks for the suggestions. After digging through the code more I got it to work by using htmlentities on the variables before getting the data with $_REQUEST[$variable]; Now it is working fine.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.