Title |
: |
php.explode |
Purpose |
: |
To break a string into an array |
Syntax |
: |
[php.explode p1=’separator’ p2=’string’ p3=’limit’ o.set=’variable name’ /]
|
Input Parameters |
: |
p1 |
: |
Required parameter. It specifies where to break the string |
p2 |
: |
Required parameter. The string to split |
p3 |
: |
Optional parameter. Specifies the number of array elements to return. Possible values:
- Greater than 0 – Returns an array with a maximum of limit element(s)
- Less than 0 – Returns an array except for the last -limit elements()
- 0 – Returns an array with one element
- If ignored – Returns an array with all element(s)
|
|
Return Value |
: |
Returns an array of strings |
Example 1 |
: |
Code |
: |
[php.explode p1=”,” p2=”one,two,three,four” p3=”2″ o.set=template.array /]
[template.array.dump /]
|
Output |
: |
0 => string(3) “one” 1 => string(14) “two,three,four” |
Description |
: |
It will seperate the string “one,two,three,four” by seperator comma (,) and return only 2 elements to the variable (template.array) |
|
Example 2 |
: |
Code |
: |
[php.explode p1=”,” p2=”one,two,three,four” p3=”-1″ o.set=template.array /] |
Output |
: |
0 => string(3) “one” 1 => string(3) “two” 2 => string(5) “three” |
Description |
: |
It will seperate the string “one,two,three,four” by seperator comma (,) and return only 3 elements to the variable (template.array) |
|
Example 3 |
: |
Code |
: |
[php.explode p1=”,” p2=”one,two,three,four” p3=”0″ o.set=template.array /] |
Output |
: |
0 => string(18) “one,two,three,four” |
Description |
: |
It will seperate the string “one,two,three,four” by seperator comma (,) and return only 1 element to the variable (template.array) |
|
Example 4 |
: |
Code |
: |
[php.explode p1=”,” p2=”one,two,three,four” o.set=template.array /] |
Output |
: |
0 => string(3) “one” 1 => string(3) “two” 2 => string(5) “three” 3 => string(4) “four” |
Description |
: |
It will seperate the string “one,two,three,four” by seperator comma (,) and return all the elements to the variable (template.array) |
|