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
)