- strstr function
- $email = ' liruxing1715@sina.com@qq.com ';
- $domain = Strstr ($email, ' @ ');
- echo "strstr test result: {$domain}
";
- $domain = Strstr ($email, ' @ ', true);
- echo "strstr test result: {$domain}
";
- /*
- The test results are:
- STRSTR test Result: @sina. com@qq.com
- STRSTR test Result: liruxing1715
- */
- ?>
Copy CodeNote: If the string you are looking for is not found, then return FALSE. 2, Stristrstristr-function and strstr function, the only difference is that the case is unclear. 3, STRRCHRstrrchr-displays the last found, the string to find, and the following string.
- STRRCHR function
- $email = ' liruxing1715@sina.com@qq.com ';
- $domain = STRRCHR ($email, ' @ ');
- echo "STRRCHR test result: {$domain}
";
- /*
- The test results are:
- STRRCHR test Result: @qq. com
- */
- ?>
Copy CodeNote: If the string you are looking for is not found, then return FALSE. 4. substrsubstr-in a string, the character is intercepted according to the given length. Format: String substr (string $string, int $start [, int $length]) parameter description: $string: the string to intercept; $start: The starting position to intercept, starting from 0 by default, if Start is A negative number, the returned string starts at the end of the $string $start character, or FALSE if the length of the string is less than or equal to start. $length: The end position of the intercept, if the first $length is empty, then return from the start position to the end.
- substr function
- $email = ' liruxing1715@sina.com@qq.com ';
- $domain = substr ($email, 10);
- echo "substr test result: {$domain}
";
- $domain = substr ($email, 10, 5);
- echo "substr test result: {$domain}
";
- $domain = substr ($email,-5, 5); The last digit of the string is-1
- echo "substr test result: {$domain}
";
- /*
- The test results are:
- SUBSTR test Result: 15@sina.com@qq.com
- SUBSTR test Result: 15@si
- SUBSTR test Result: q.com
- */
- ?>
Copy Code |