1.trim: Remove whitespace characters (or other characters) from the end of a string
eg
$text = " There is a few words. ";
Print_r (Trim ($text));
2.ltrim: Remove the left white space character.
3.rtrim: Remove the white space character to the right.
4.str_pad (): fills the string as required. The first argument is the string to fill, the second is the padding length, the third parameter is the fill symbol,
The fourth parameter is the direction of the fill (
Str_pad_left: String left fill.
Str_pad_right : String right fill.
Str_pad_both: String ends fill
)
eg
$input = "Alice.";
Echo Str_pad ($input, 10, "-="); alice.-=-=
Echo Str_pad ($input, "* *", str_pad_both); alice.*****
5.strtolower (): string str all lowercase strings.
6.strtoupper (): This function converts the string str to all uppercase strings.
7.ucfirst (): The first character of the string is changed to uppercase.
8.ucwords (): string The first letter of each word is capitalized.
9.NL2BR (): Converts the string "\ n" to the HTML line break "<br/>"; the second parameter indicates whether to use XHTML-compatible line breaks
eg
Echo nl2br ("Welcome\r\nthis is my HTML document", false);//welcome
This is my HTML document
10.htmlspecialchars (): Turn the specified special symbols into entities, such as <>, etc.
eg
Echo htmlspecialchars ("<a href= ' # ' >Test</a>");//<a href= ' # ' >Test</a>
11.strip_tags (): Removes HTML and PHP tags from the string.
eg
$text 1 = "<p>test paragraph.</p><!--Comment--><a href= ' # ' >other text</a>";
echo $text 1;//test paragraph.
Other text
12.strrev (): Reverses the string backwards. Reverses the string.
$text 2 = "Hello World";
Echo Strrev ($text 2);//dlrow Olleh
13.strlen (): Gets the string length.
14.number_format (): Format a number in thousands separators
eg
$number = 1234.56;
echo Number_format ($number);//1,235
echo Number_format ($number, 2);//1,234.56
echo Number_format ($number, 2, ",", "");//1234,56
15.MD5 (): cryptographic function
16.STRCMP (): Binary secure string comparison
eg
$var 1 = "Hello";
$var 2 = "Hello";
if (strcmp ($var 1, $var 2)!== 0) {
echo "$var 1 is not equal to $var 2 in a case sensitive string Comarison";
}
17.STRNCMP (): Binary security compares several characters at the beginning of a string, similar to strcmp, except that you can specify the length that is used when two string comparisons are made.
eg
$arr 1 = $arr 2 = Array ("Img12.png", "Img10.png", "Img2.png", "img1.png");
Usort ($arr 1, "strcmp");//array ([0] = img1.png [1] = = Img10.png [2] = = Img12.png [3] = = img2.png)
18.STRCASECMP (): Binary Security comparison string (case insensitive)
19.STRNATCMP (): Comparing strings using natural sorting algorithms
eg
$arr 1 = $arr 2 = Array ("Img12.png", "Img10.png", "Img2.png", "img1.png");
Usort ($arr 2, "strnatcmp");//array ([0] = img1.png [1] = = Img2.png [2] = = Img10.png [3] = = img12.png)
20.similar_text (): Calculates the similarity of two strings
PHP's Common string method