- $ Str = '000000 ';
- $ Needle = '20140901 ';
- $ Result = strchr ($ str, $ needle );
- Var_dump ($ result );
Result: string '20140901' (length = 9)
Strrpos searches for the last occurrence of a character in the string. Syntax: int strrpos (string haystack, char needle );
This function is used to find the final position of the character needle in the haystack string. Note that the needle can only be one character, and it is not suitable for Chinese characters. If the specified character is not found, false is returned.
Strpos searches for the first occurrence of a character in a string.
Syntax: int strpos (string haystack, string needle, int [offset]);
This function is used to find the first position where the character needle in the haystack string appears. Note that the needle can only be one character, and it is not suitable for Chinese characters. If the specified character is not found, false is returned. The offset parameter can be omitted, which is used to start searching from offset.
Strspn identifies the number of masks that a string falls on another string.
Syntax: int strspn (string str1, string str2 );
This function uses the str2 string as the mask and can be used to calculate the number of characters in the str1 string that fall into the str2 mask. Php string comparison and search methods detailed description php comparison string similarity function usage reference PHP string comparison function strcmp () and strcasecmp () usage introduction php comparison string similarity instance code |