Definition and usage
The explode () function splits the string into arrays.
Grammar
Explode (separator,string,limit) parameter description
Separator required. Specifies where to split the string.
string is required. The string to split.
Limit is optional. Specifies the maximum number of array elements that are returned.
Description
This function returns an array of strings, each of which is a substring separated by separator as a boundary point.
The separator parameter cannot be an empty string. If separator is an empty string (""), Explode () returns FALSE. If separator contains a value that is not found in a string, explode () returns an array containing a single element in the string.
If the limit parameter is set, the returned array contains a maximum of limit elements, and the last element will contain the remainder of the string.
If the limit parameter is a negative number, all elements except the last-limit element are returned. This feature is new in PHP 5.1.0.
Hints and Notes
Note: The parameter limit is added in PHP 4.0.1.
Note: For historical reasons, although implode () can receive two parameter sequences, explode () does not work. You must ensure that the separator parameter is not preceded by a string parameter.
Example
In this example, we will split the string into arrays:
<? PHP $str = "Hello World". It ' s a beautiful day www.juhutang.com "; Print_r (Explode("",$str)); // $url =explode ("", $str); This is only a demonstration//echo $url [0];? >
Output:
Array ([0] = = hello[1] = world. [2] = It 's[3] = a[4] [beautiful[5] = day[6] = www.juhutang.com)
If the output $url [0] that is:
Hello