Or use strcmp to determine, but this can tell you whether the two strings are equal, but it cannot tell you where they are different.
My idea is to split a single string into letters (character), so that you can know exactly where it is.
Use "str_split" to separate strings. For the syntax, refer to [2 ]. Then output the result array. The advantage is that even spaces are used as elements of the array. In my previous example, the previous string contains two spaces, and the next string has only one space. However, the output displays the same information.
You can also use other separators, such as "explode" or "preg_split". For more information, see [3] and [4 ]. The former uses a simple split number, and the latter uses a regular expression. "Split" has been abolished (deprecated.
Another useful function is "str_word_count", which can split strings into arrays and clear numbers and punctuation marks at the same time. If you want to calculate the frequency of occurrence of a word, you can use "array_count_values". For details, refer to [5 ].
Refer:
[1] http://us2.php.net/manual/en/language.operators.comparison.php
[2] http://us2.php.net/manual/en/function.str-split.php1
[3] http://us2.php.net/manual/en/function.explode.php
[4] http://us2.php.net/manual/en/function.str-split.php
【5】 http://us2.php.net/manual/en/function.array-count-values.php
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.