A
A
Alexander2015-11-03 15:12:15
PHP
Alexander, 2015-11-03 15:12:15

How to compare two strings with different characters?

Friends.
I compare two identical-looking strings
it's a date
it's a date
which in the end turn out to be unequal.

$mysername = trim(stripslashes(strtolower($myrow2['origname'])));
$parssername = trim(stripslashes(strtolower($origname['1'])));

Here are the encodings:
mb_detect_encoding($mysername) // ASCII
mb_detect_encoding($parssername) // ASCII

var_dump(htmlspecialchars($mysername, ENT_QUOTES, ''));
var_dump(htmlspecialchars($parssername, ENT_QUOTES, ''));
This is what var_dump(htmlspecialchars()) outputs:
string(16) "it's a date" 
string(20) "it's a date"

Here is the output:
var_dump(bin2hex($mysername));
var_dump(bin2hex($parssername));
string(22) "6974277320612064617465" 
string(32) "697426233033393b7320612064617465"

Those. for some reason, a single quote is not converted.
How can they be compared?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
I
Ivanq, 2015-11-03
@Ivanq

htmlspecialchars_decode($mysername) == htmlspecialchars_decode($parssername)

S
Sergey, 2015-11-03
Protko @Fesor

How can they be compared?

take character code.

D
Dmitry, 2015-11-03
@mytmid

Maybe this will help:
1. Convert ASCII to UTF-8: iconv
2. Must be disabled on hosting: magic_quotes
3. Be sure to use PHP version 5.4 or older.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question