PHP: describes some common string manipulation functions
18. Str_pad (): Padding string to specified length Padding string to specified length
$str = “Hello World”;
echo str_pad($str,20,”.”);
Input: to fill new string string | | for the use of filling the length of the string, the default is blank
Output: Hello World……… (Completed string)
19. Str_repeat (): Repeat the specified string
echo str_repeat(“.”,13);
Input: repeat | string string will be repeated
The command output is…………. (13)
20. Str_split (): Split string into array
print_r(str_split(“Hello”));
Input: to split the length of the string | each array element, 1 by default
Output: Array ([0] = > H [1] [2] = > = > e l [3] [4] = > = > l o) after the splitting of (an Array of strings)
21. Strrev (): Reverses string reverses string
echo strrev(“Hello World!” );
Input: String to be flipped
Output:! DlroW olleH(the string after the destination string is reversed)
Wordwrap (): Folds a string to the specified length
$str = “An example on a long word is:Supercalifragulistic”;
echo wordwrap($str,15);
Input: the target string | wide largest number
An example on a long word is:Supercalifragulistic
23. Str_shuffle (): Randomly shuffles all characters in a string
echo str_shuffle(“Hello World”);
Input: Target string order
Output: Scrambled string
24. Parse_str (): Parses strings into variables
parse_str(“id=23&name=John%20Adams”, $myArray);
print_r($myArray);
Input: to parse the string | variable storage array name
Array([id] => 23 [name] => John Adams)
25. Number_format (): Format numbers by thousands groups
echo number_format(20000000000);
Figures to be formatted input: how many decimal | | regulations provisions is used as the decimal point character string | for one thousand points
A string of delimiters
Output: 20000000000
26. Strtolower (): String to lowercase String to lowercase
echo strtolower(“Hello WORLD!” );
Enter: target string
Output: Hello world! (All lowercase strings)
27. Strtoupper (): Uppercase string Uppercase string
echo strtoupper(“Hello WORLD!” );
Enter: target string
Output: HELLO WORLD! (All uppercase strings)
28. Ucfirst (): Uppercase The first letter of the string is uppercase
echo ucfirst(“hello world”);
Enter: target string
Output: Hello world(the first letter of the string is capitalized)
29. Ucwords (): Uppercase the first character of each word in a string is uppercase
echo ucwords(“hello world”);
Output: Hello World(capitalize the first letter of each word)
For more technical information: Gzitcast