Array of string turns
$str = ' One|two|three|four ';p rint_r (Explode (' | '), $STR); Explode string to array
$str = ' one three '; Str_split is divided into bits $arr1 = Str_split ($STR), $arr 2 = Str_split ($str, 3);p Rint_r ($arr 1);p Rint_r ($arr 2);
Print as follows:
Array ( [0] = = o [1] = n [2] = + E [3] = = [4] = [5] = w [6] = = O
[7] [8] [+] = [ 9] = h [ten] = R [One] ~ + e [+] + e) Array ( [0] = = One [1] = tw [2] = O T [3] = = HRE [4] = = e)
Array to String
Inplode ()
String interception
The substring method is used to extract the character of a string intermediary between two specified subscripts
SUBSTRING (start,end)
The Substr method is used to return a substring of the specified length starting at the specified position.
SUBSTR (start [, length])
Replace
Str_replace ()
Replace the character "world" in the string "Hello world!" with "Shanghai":
echo Str_replace ("World", "Shanghai", "Hello world!");
Preg_replace: Perform a search and replace of a regular expression
Find
Preg_match ();
Preg_grep ();
PHP: String to array, array to string, string intercept, replace, find