字符串的分割与拼接:
1.explode();
把字符串打散为数组:
**
<?php
$str = "Hello world. I love Shanghai!";
print_r (explode(" ",$str));
?>
**
Array ( [0] => Hello [1] => world. [2] => I [3] => love [4] => Shanghai! )
2.implode();
把数组元素组合为字符串:
**
<?php
$arr = array('Hello','World!','I','love','Shanghai!');
echo implode(" ",$arr);
?>
**
Hello World! I love Shanghai!
3.join();
把数组元素组合为一个字符串:
**
<?php
$arr = array('Hello','World!','Beautiful','Day!');
echo join(" ",$arr);
?>
**
Hello World! Beautiful Day!