PHP function explode()
Availability in PHP 4.0
Parses a string according to the string type separator. Cannot set multiple delimiters.
Parameters
| Parameter | Data type | Default value | Note |
|---|---|---|---|
$delimiter |
string |
not | Separator string |
$string |
string |
not | Input string |
$limit |
int |
null | When the limit is a positive number, the returned array will contain at most as many elements as the limit. The last element of the array will possibly contain additional unparsed values that did not fit into the array. If the limit is negative, it is parsed from the end of the string. |
Return values
array
Returns an array of elements obtained by the separator.
If the separator is empty, it returns false.
If the delimiter contains a value that is not contained in the string and a negative limit is used, an empty array will be returned. For other limit settings, it will return an array with a single element with the original string unchanged.
php
$items = explode(',', '2,4,6,8');foreach ($items as $item) {echo $item . '<hr>';}