PHP explode() function is often used to split a string into an array by a specified string.
Syntax
array explode(delimiter,str,limit);
Parameter | Description |
---|---|
delimiter : | Required parameter. The boundary string. |
str : | Required parameter. The input string. |
limit : | Required parameter. The number of array elements to be return.
|
Return Value : | Returns an string array splitted with delimiter. |
<?php $str = 'James|Scott|Manager|29|7428323323'; // Zero limit echo explode('|',$str,0); // Greater than 1 limit echo explode('|',$str,2); // Less than 1 limit echo explode('|',$str,-1); ?>