The explode() function used to break an string into array
explode(string $separator , string $string ,int $limit = PHP_INT_MAX ) : array
Parameter Name | Descrption |
---|---|
separator | Required, specifies separator to break the string |
string | Required, string |
limit | Optional, Set the limit for the return number of elements
|
Returns the array
$string = 'This is test string'; $arary = explode(' ',$string); print_r($arary); Array ( [0] => This [1] => is [2] => test [3] => string ) $arary = explode(' ',$string,0); print_r($arary); Array ( [0] => This is test string ) $arary = explode(' ',$string,2); print_r($arary); Array ( [0] => This [1] => is test string ) $arary = explode(' ',$string,-2); print_r($arary); Array ( [0] => This [1] => is )
Related Functions