Remove Space trim ($ processed string, $ to remove string) LTrim RTrim
<? php$ss= "D I am a tesad"; $s =trim($ss, ' d '); echo $s;? >
Corresponds to Python:a.lstrip (), A.rstrip (), A.strip (), A.strip ("ACC")
Inserts a character in a string chunk_split ($ processed string, interval, inserted string)
<?php
Echo chunk_split ("Iamasmallgogo", 2, ","); Ia,ma,sm,al,lg,og,o,
Echo chunk_split ("Iamasmallgogo", 1, ","); I,a,m,a,s,m,a,l,l,g,o,g,o,
?>
The frequency of occurrences of individual characters in a numeric character string Count_chars ($ processed string, pattern)
<?php
$data = "I have some II habasome";
Var_dump (Count_chars ($data, 1));
Var_dump (Count_chars ($data, 3));
?>
Array (10) {
[32]=>int (4)
[97]=>int (3)
[98]=>int (1)
[101]=>int (3)
[104]=>int (2)
[105]=>int (3)
[109]=>int (2)
[111]=>int (2)
[115]=>int (2)
[118]=>int (1)
}
String (Ten) "Abehimosv"
Sets the string by delimiter array explode ( string $delimiter
, string $string
[, int $limit
])
<?php
$data = "I have some II habasome";
Var_dump (Explode ("", $data));
Var_dump (Explode ("", $data, 2));
?>
Array (5) {
[0]=>
String (1) "I"
[1]=>
String (4) "has"
[2]=>
String (4) "some"
[3]=>
String (2) "II"
[4]=>
String (8) "Habasome"
}
Array (2) {
[0]=>
String (1) "I"
[1]=>
String (*) "has some II Habasome"
}
Link an array into a string by delimiter
string
implode ( string
$glue
, array
$pieces
) string
implode ( array
$pieces
) alias join
<?php
$array = Array (' LastName ', ' email ', ' phone ');
$comma _separated = Implode (",", $array);
echo $comma _separated; Lastname,email,phone
?>
string lcfirst $str
- makes the first character of a string lowercase
string MD5 ( string $str
[, bool $raw_output
= false]) computes the MD of the string 5 Hash value
string nl2br ( string $string
[, bool $is_xhtml
= TRUE
]) Inserts an HTML wrap tag before all new lines in the string
string Str_pad (string $input
, < Span class= "type" >int $pad _length
[, String $pad _string
= "" [, int $pad _type
= Str_pad_right]]) fills the string to the specified length /span>
< Span class= "Methodparam" > strin G str_repeat (string $input
, int $ Multiplier
) Repeat $input $mutiplier times
Str_replace Replacement string
<?php
$s = "I am jack, I like CB, I have always been nice";
$c = 2;
echo str_replace (' Jack ', ' Tom ', $s). " \ n ";
Echo str_replace ([' Jack ', ' CB ', ' nice '],[' Tom ', ' RB ', ' bad '], $s). " \ n ";
?>
I'm jack, I like CB, I've always been nice.
I'm Tom, I like RB, I've always been bad.
String str_shuffle ( string $str
)
<?php
$str = "Hello Friend";
$arr 1 = str_split ($STR);
$arr 2 = Str_split ($STR, 3);
Print_r ($arr 1);
Print_r ($arr 2);
?>
Array ( [0] = H [1] ~ = e [2] = = L [3] = = L [4] = O [5] = = [6] = = F [7] = = R [8] = i [9] = = e [ten] = n [one] + D) Array ( [0] = Hel [1 ] = Lo [2] = = Fri [3] = + END)
int
stripos ( string
$haystack
, string
$needle
[, int
$offset
= 0])
Returns haystack
needle
the number position of the first occurrence in a string.
int
strpos ( string
$haystack
, mixed
$needle
[, int
$offset
= 0])
returns needle
the haystack
number position that first appears in the.
string
strrev ( string
$string
)
Returns string
the inverted string.
;;;;;;;;; don't want to write ...
PHP string processing