I am trying to compare rows from 2 PHP arrays like this...
if ($row1[$i] == $row2[$i]) {
echo 'Rows match';
} else {
echo 'Rows do not match';
}
This is working correctly until it comes across something that is encoded, so apostrophe is a good example. So the below 2 are not equal...
This is an apostrophe'
This is an apostrophe'
I have tried using htmlspecialchars_decode
to attempt to convert them before comparing but this is not working. How can I compare these 2 rows?
CodePudding user response:
Try html_entity_decode()
with ENT_QUOTES
flag
https://www.php.net/manual/en/function.html-entity-decode.php
html_entity_decode('This is an apostrophe'', ENT_QUOTES);