The explode() function is used to split a string into an array.
Syntax: explode(separator,string[,limit]);
separator – the character or characters at which the string should be split.
string – the input string
limit – the maximum number of array elements you allow the string to be split into.
Example inputs:
1.
$str= "This is a simple program";
print_r(explode(" ",$str));
2.
$str= "This is a simple program";
print_r(explode(" ",$str,3));
Carefully note the difference in output between the two examples.
Example outputs:
1.
Array ( [0] => This [1] => is [2] => a [3] => simple [4] => program )
2.
Array ( [0] => This [1] => is [2] => a simple program )
1 comment:
Thx for the tutes. I can tell you that they really come in handy.
Post a Comment