One, take partial string.
Copy Code code as follows:
String substr (string string, int start, int [length]);
This function extracts the length character of the string from the start of string strings. If start is a negative number,
is calculated from the end of the string. If the parameter length that can be omitted exists but is negative, it is taken to the penultimate length character.
Copy Code code as follows:
echo substr ("abcdef", 1, 3); Return "BCD"
echo substr ("ABCdef",-2); Return to "EF"
echo substr ("ABCdef",-3, 1); Return "D"
echo substr ("abcdef", 1,-1); Return to "BCDE"
Second, get the last occurrence of a character string.
Copy Code code as follows:
String STRRCHR (String haystack, string needle);
This function is used to find the last occurrence of the character needle in the string haystack, and to place this position in the string
Haystack end of String return. Returns False if needle is not found.
Copy Code code as follows:
$PATH = "http://localhost/test/test.php";
$dir = substr (STRRCHR ($PATH, ":"), 1);
Echo $dir;
Output://localhost/test/test.php
Returns the string at the beginning of a string to the end of a character string.
Copy Code code as follows:
String Strstr (String haystack, string needle);
This function returns the needle string that first appears at Haystack to the end of haystack. Returns False if needle is not found.
Four, string alignment parsing.
Copy Code code as follows:
int Ereg (string pattern, string string, array [regs]);
This function resolves string strings using pattern rules. The value returned by the result is placed in the array parameter regs, Regs[0] content is the original string string, Regs[1] is the first regular string, regs[2] is the second rule string, and so on. If the argument regs is omitted, the return value is true only if it is simply compared.
Copy Code code as follows:
if (eregi ("^ [_/.0-9a-z-] +@" ([0-9a-z] [0-9a-z-] +/.) + [A-Z]{2,3}$ ", $email)) {
echo "Your e-mail through preliminary check";
}