explode()
函数用于将字符串分割成数组。其语法为:
explode(separator, string, limit)
参数说明:
separator
:必需。指定在哪里分割字符串。string
:必需。要分割的字符串。limit
:可选。规定所返回的数组元素的最大数目。示例:
$str = "apple,banana,orange,grape";
$arr = explode(",", $str);
print_r($arr);
输出:
Array
(
[0] => apple
[1] => banana
[2] => orange
[3] => grape
)