This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
uphp:functions:explode [2017/04/04 13:09] jeff |
uphp:functions:explode [2021/09/13 05:57] (current) |
||
---|---|---|---|
Line 3: | Line 3: | ||
< | < | ||
- | Turn a < | + | < |
====Description==== | ====Description==== | ||
- | <well size=" | + | <well size=" |
- | <span style=" | + | <span style=" |
- | < | + | <span style=" |
<span style=" | <span style=" | ||
<span style=" | <span style=" | ||
Line 16: | Line 16: | ||
<span style=" | <span style=" | ||
</ | </ | ||
- | Turn a < | + | < |
====Parameters==== | ====Parameters==== | ||
- | < | + | < |
< | < | ||
- | ====Return | + | ====Return |
< | < | ||
Line 46: | Line 46: | ||
(string) [3] => four | (string) [3] => four | ||
) | ) | ||
+ | ?></ | ||
+ | </ | ||
+ | |||
+ | Note that if only one element is present (without the separator character) then a value of -1 will be returned. | ||
+ | |||
+ | <code php> | ||
+ | < | ||
+ | $mylist=" | ||
+ | $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==== | ====See Also==== | ||
- | [[implode()]] - Turn an < | + | [[implode()]] - < |
[[print_r()]] - Dump the contents of an < | [[print_r()]] - Dump the contents of an < |