0

I need compare two string. Visually they compare, but var_dump result other. Help me please.

string(8) "СИ.pdf" string(7) "CИ.pdf"

How correct compare him?

Maksim Borodov
  • 419
  • 2
  • 7
  • 13
  • 2
    Most likely the strings are in different encoding. You will have to find out why that is, so that you can prevent such thing in future. Do _not_ search for some automatic encoding conversion, _that will not work_. Use a `hexeditor` if you want to understand what you see. – arkascha Mar 26 '17 at 10:20
  • you have to [`setlocale`](http://php.net/manual/en/function.setlocale.php) – Deadooshka Mar 26 '17 at 10:26

2 Answers2

1

Use mb_convert_encoding() to convert both versions to something reasonable (UTF8 for example) then use mb_strstr() to do the comparison.

mayersdesign
  • 5,062
  • 4
  • 35
  • 47
-1

most likely there are some non printable characters in the string

check out the following : PHP: How to remove all non printable characters in a string?

Community
  • 1
  • 1
Arie
  • 96
  • 4