用自定義分隔符把字符串分割為數(shù)組:
以上輸出內(nèi)容:
Array(
[0] => Hello
[1] => world
[2] => w3cschool
)
explode() 函數(shù)把字符串打散為數(shù)組。
注釋:"separator" 參數(shù)不能是一個(gè)空字符串。
注釋:該函數(shù)是二進(jìn)制安全的。
相關(guān)函數(shù):implode()用自定義連接符把數(shù)組組成字符串
參數(shù) | 描述 |
---|---|
separator | 必需。規(guī)定在哪里分割字符串。 |
string | 必需。要分割的字符串。 |
limit | 可選。規(guī)定所返回的數(shù)組元素的數(shù)目。 可能的值:
|
返回值: | 返回字符串?dāng)?shù)組。 |
---|---|
PHP 版本: | 4+ |
更新日志: | 在 PHP 4.0.1 中,新增了 limit 參數(shù)。在 PHP 5.1.0 中,新增了對(duì)負(fù)數(shù) limits 的支持。 |
使用 limit 參數(shù)來返回一些數(shù)組元素:
以上輸出內(nèi)容
Array
(
[0] => one,two,three,four
)
Array
(
[0] => one
[1] => two,three,four
)
Array
(
[0] => one
[1] => two
[2] => three
)