1. String Split function str_split ($str, length), $str is the string to be cut, length is the split length, the default is 1 if it is a negative number, false
1 $str= ' helloworld! ' ; 2 Print_r (str_split($str, 2)); 3 Echo ' <br> '; 4 Print_r (str_split($str));
Output Result:
Array ([0] = He [1] = ll [2] = = ow [3] = or [4] = ld [5] = =!)
Array ([0] = h [1] = e [2] = + [3] = l [4] = = O [5] = w [6] = o [7] = R [8] = l [9] =& Gt d [Ten] =! )
2. String reversal function Strrev ($STR), returns the string in reverse
$str= ' Hello World '; Echo Strrev ($str);
Output Result: Dlrow Olleh
3.chunk_split ($str, length, $s), divides str into substrings of length lengths and adds the string s later, and finally joins to return the new string
$str= ' language '; Echo Chunk_split ($str, 2, ', ');
Output Result: La,ng,ua,ge,
4. Remove the left character function LTrim ($str, $s)and remove $s from the left side of $str
$str= ' HelloWorld '; $s= ' hello '; Echo LTrim ($str,$s);
Output: World
5. String converted to uppercase function Strtoupper ($STR) and converted to lowercase function strtolower ($str)
$str= ' Hello World '; $str 1=strtoupper($str); Echo $str 1, ' <br> '; $str 2=strtolower($str 1); Echo $str 2;
Output Result:
HELLO World
Hello World
PHP Learning Notes-string practice continuation