Phpstrstr () strrchr () strpos () strrpos () function. These four functions are character operation functions, mainly used to determine the number of occurrences of a character. For more information, see. The code is as follows: Copy the code? Phpstrstr: Returns from left to right. these four functions are character operation functions, mainly used to determine the number of occurrences of characters. if you need them, refer to them.
| The code is as follows: |
|
// Strstr: returns value from left to right: string // Strrchr: returns a string from right to left. // Strpos: return value from left to right: Integer. if the searched string does not exist, null is returned. // Strrpos: return value from right to left: integer $ Str = "sky high, birds fly, sea wide, fish jump"; // strstr: Search from left to right strrchr: Search from right to left Echo "original string:". $ str ." "; Echo "returns the result of searching", "using the strstr function:". strstr ($ str ,",")." "; Echo "returns the result of searching" bird fly "using the strstr function:". strstr ($ str, "Bird fly ")." "; $ Str1 = "I have a great dream ."; Echo "original string:". $ str1 ." "; Echo "returns the result of searching" e "using the strrchr function:". strrchr ($ str1, "e ")." "; Echo "use the strrchr function to search for the returned result of" ea ":". strrchr ($ str1, "ve ")." "; $ Str2 = "I am an abstract about abroad ."; Echo "original string:". $ str2 ." "; Echo "the first occurrence position of AB in the string is:". strpos ($ str2, "AB ")." "; Echo "the first occurrence position of AB in the string is:". strpos ($ str2, "am ")." "; Echo "the location where abcd first appears in the string is:". strpos ($ str2, "aman ")." "; $ Str3 = "I am is wang hui ."; Echo "original string:". $ str3 ." "; Echo "the last occurrence position of I in the string is:". strrpos ($ str3, "I ")." "; Echo "the last appearance position of an in the string is:". strrpos ($ str3, "")." "; Echo "the last occurrence of I in the string is:". strrpos ($ str3, "I "); ?> |
Bytes. The code is as follows? Php // strstr: Search from left to right and return...