目前PHP函數explode()把字符串分割為數組
explode(separator,string,limit)
separator 必需。規定在哪裡分割字符串。
string 必需。要分割的字符串。
limit 可選。規定所返回的數組元素的最大數目。
PHP函數explode()例子
- <?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.
- )
以上代碼示例就是PHP函數explode()的具體使用。