These four functions are character manipulation functions, mainly to determine the number of occurrences of characters, the need for friends can refer to.
| The code is as follows |
Copy Code |
STRSTR: Find return value from left to right: string STRRCHR: Right-to-left lookup return value: string Strpos: Find return value from left to right: integer, if the found string does not exist, returns an empty Strrpos: Right-to-left lookup return value: integer $STR = "High-flying birds, sea-wide diving";//strstr: Find strrchr from left to right echo "Raw string:". $str. " "; echo "Search with strstr function", "return Result:". Strstr ($str, ","). " "; echo "uses the STRSTR function to search for" bird Fly "return results:". STRSTR ($str, "Bird Fly"). " "; $str 1= "I have a great dream."; echo "Raw string:". $str 1. " "; echo "Searches for the return result of" E "with the STRRCHR function:". STRRCHR ($str 1, "E"). " "; echo "Searches for the return result of the EA using the STRRCHR function:". STRRCHR ($str 1, "VE"). " "; $str 2= "I am an abstract about abroad."; echo "Original string is:" $str 2. " "; The first occurrence of echo "AB in the string is:". Strpos ($str 2, "AB"). " "; The first occurrence of echo "AB in the string is:". Strpos ($str 2, "AM"). " "; The first occurrence of echo "ABCD in a string is:". Strpos ($str 2, "Aman"). " "; $str 3= "I am is Wang Hui."; echo "Original string is:" $str 3. " "; The last occurrence of echo "I in the string is:". Strrpos ($str 3, "I"). " "; The last occurrence of echo "an in the string is:". Strrpos ($str 3, "an"). " "; The last occurrence of echo "I in the string is:". Strrpos ($str 3, "I"); ?> |
http://www.bkjia.com/PHPjc/631322.html www.bkjia.com true http://www.bkjia.com/PHPjc/631322.html techarticle These four functions are character manipulation functions, mainly to determine the number of occurrences of characters, the need for friends can refer to. Code to copy code like this? PHP//strstr: Left-to-right lookup return ...