This function operates on bytes, not characters, so it is only of limited use when operating on UTF-8 encoded Unicode strings.
Running the input strings through Normalizer ( https://www.php.net/manual/en/class.normalizer.php ) can at least somewhat help with this, but you still need to be aware that replacing, inserting or deleting a single UTF-8 encoded unicode character can wrongly report a cost of 2, 3 or 4 depending on the length of the UTF-8 sequence representing it, or even more when dealing with combining character modifiers.