1, Chop ()
Remove a character from the right end of a string
Chop (string,charlist)
$str= "Hello world~"; Echo Chop ($str, "ld~"); // Hello wor
PS. charlist parameter is optional, if not, the default is to remove
- "+"-NULL
- "\ T"-tab
- "\ n"-line break
- "\X0B"-Vertical tab
- "\ r"-Enter
- ""-Space
2, Chunk_split ()
Splits a string into a series of smaller parts.
Chunk_split (String,length,end)
$str= "Hello world~"; Echo Chunk_split ($str, 1, "."); // H.E.L.L.O. w.o.r.l.d.~.
3, Explode ()
Breaks the string into arrays.
Explode (Separator,string,limit)
$str= "beijing,shanghai,nanjing,tianjing,anqing"; Print_r (explode(",",$str, 3)); // Array ([0] = Beijing [1] = Shanghai [2] = nanjing,tianjing,anqing)
PS. Limit optional, which specifies the number of array elements returned.
4, Htmlspecialchars ()
Converts a pre-defined character to an HTML entity.
Htmlspecialchars (String,flags,character-set,double_encode)
$str= "Hello <em>world</em>~"; Echo Htmlspecialchars ($str); // Hello <em>world</em>~
- & (and number) becomes &
- "(double quotes) becomes"
- ' (single quote) become '
- < (less than) becomes <
- > (greater than) becomes >
5, implode ()//alias Join ()
Returns a string that is composed of array elements.
Implode (Separator,array)
$arr=array("shanghai,nanjing,beijing,tianjing,anqing"); Echo implode ("",$arr); // shanghai,nanjing,beijing,tianjing,anqing
PS. separator is optional. Specifies what is placed between the elements of the array. The default is "" (an empty string).
6, Lcfirst ()
Converts the first character in a string to lowercase.
Lcfirst (String)
$arr= "Hello World"; echo lcfirst ($arr); // Hello World
PHP string Important functions