$mylist="one,two,three,four";
$myarray=explode($mylist,",");
print_r($myarray);
?>
The above example will output:
[$myarray] = Array (
(string) [0] => one
(string) [1] => two
(string) [2] => three
(string) [3] => four
)
?>
Note that if only one element is present (without the separator character) then a value of -1 will be returned. This differs from the PHP implementation.
$mylist="one";
$myarray=explode($mylist,",");
// the fix for a single parameter is to use is_array
if (!is_array($myarray)) {
$myarray=array($mylist);
}
print_r($myarray)
?>
====See Also====
[[implode()]] - Turn an array into a string
[[print_r()]] - Dump the contents of an array to the current output
[[sizeof()]] - Return the number of elements in an array
[[uphp:variables|uPHP Variable Types and Limits]]
====Additional Information====
Note that there is an important difference in the parameter order between mainline PHP and Wattmon uPHP. In the mainline PHP function the delimiter comes first, but in uPHP the string to be exploded comes first: