PHP explode


explode(sep,string) split a string into an array of substrings based on the specified separator.

<?PHP
	$str="The best time is no time";
	$arr=explode(" ",$str);
	foreach($arr as $i) echo "$i, ";  //The, best, time, is, no, time, 
?>

The separator can also be a string.
<?PHP
	$str="The best time is no time";
	$arr=explode("time",$str);
	foreach($arr as $i) echo "$i, ";  //The best , is no , , 
?>

If the returned array element number n is specified, then the return array will be consisted of the first n-1 elements, and all the remaining elements will be combined into the last element.
<?PHP
	$str="The best time is no time";
	$arr=explode(" ",$str,3);
	foreach($arr as $i) echo "$i, ";  //The, best, time is no time, 
?>

If the specified return element number n < 0, then return all other elements except the last n elements.
<?PHP
	$str="The best time is no time";
	$arr=explode(" ",$str,-1);
	foreach($arr as $i) echo "$i, ";  //The, best, time, is, no, 
?>

implode(sep,array) will combine all elements of the array into a string.
<?PHP
	$arr=array("php","js","python");
	$str=implode(" + ", $arr);
	echo "$str";  //php + js + python
?>