解讀PHP函數explode()的具體使用方法
作者:佚名
PHP函數explode()的作用就是把字符串分割為數組,具體語法為:explode(separator,string,limit)。我們將會給大家帶來具體的代碼示例,方便理解。
目前PHP語言算是相當火的一門高級語言。我們可以用它來創建一個高性能的網站等。今天我們為大家帶來的是有關PHP函數explode()的具體用法,希望能對又需要的朋友有所幫助。
#t#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()的具體使用。
責任編輯:曹凱
來源:
CSDN