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 )
Showing posts with label string to array conversion in php. Show all posts
Showing posts with label string to array conversion in php. Show all posts
Monday, September 29, 2008
Subscribe to:
Posts (Atom)