Eight, the string segmentation
Explode () function: Splits a string according to the specified rules. Returns an array.
Grammar:
Array explode (split identifier, string Str[,int limit])
Splits the string by the specified split identifier.
Cases:
<?php
$str = "Welcome to www.bianceng.cn!";
$arr =explode (".", $str);
echo "<pre>";
foreach ($arr as $key => $val) {
echo $val. " <br/> ";
}
echo "</pre>";
?>
Output:
Welcome to www
Bianceng
cn!
Nine, String synthesis
Implode () function: This function can synthesize the contents of an array into a new string
Syntax format:
Sting Imgplode (separator, array name)
Function: Concatenate the contents of the array with the specified delimiter into a string
Cases:
<?php
$str = "Welcome to www.bianceng.cn!";
$arr = Explode (".", $str);
echo "<pre>";
foreach ($arr as $key => $val) {
Echo $val. "<br/>";
}
echo "</pre>";
$str 1 = Implode ("_", $arr);
echo "<br/>". $STR 1; Output Welcome to Www_bianceng_cn!
?>