PHP explode() 函数

explode() 函数把字符串分割为数组。

explode(separator,string,limit)

separator:必需。规定在哪里分割字符串。

string:必需。要分割的字符串。

limit:可选。规定所返回的数组元素的最大数目。

例子:

<?php
$str = "Hello world. It's a beautiful day.";
print_r (explode(" ",$str));
?>

输出:

Array
(
[0] => Hello
[1] => world.
[2] => It's
[3] => a
[4] => beautiful
[5] => day.
)

 

posted @ 2012-09-28 17:51  RattanyiXu  阅读(344)  评论(0编辑  收藏  举报