Core Function Join
From Sputnik Wiki
(Difference between revisions)
m (1 revision) |
|||
(2 intermediate revisions by one user not shown) | |||
Line 1: | Line 1: | ||
<pre> | <pre> | ||
− | + | Join( <array>, <separator> ) | |
</pre> | </pre> | ||
=== Description === | === Description === | ||
− | + | Join an array into a string with an optional separator. | |
− | + | === Parameters === | |
− | + | ==== array ==== | |
− | + | The array to join. | |
− | ==== | + | ==== separator ==== |
− | Optional; | + | Optional; A string to place between each array element. |
− | + | ||
− | + | ||
+ | Default is " " a space. | ||
=== Return Value === | === Return Value === | ||
− | + | Success - The array merged into a string. | |
+ | |||
+ | Failure - Returns an empty string. | ||
=== Remarks === | === Remarks === | ||
− | + | This does not alter the original array. | |
=== Example === | === Example === | ||
− | |||
<syntaxhighlight lang="sputnik"> | <syntaxhighlight lang="sputnik"> | ||
− | $ | + | $days = Array ("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"); |
− | + | Foreach ( $days as $day ) | |
− | + | { | |
− | + | println("Element is: " . $day); | |
− | + | } | |
− | + | println("Joined together is " . join($days, ":") ); | |
− | + | // Prints: Joined together is Sun:Mon:Tue:Wed:Thu:Fri:Sat | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | ); | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | $ | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
</syntaxhighlight> | </syntaxhighlight> | ||
[[Category:Core Function]] | [[Category:Core Function]] |
Latest revision as of 12:38, 14 June 2015
Join( <array>, <separator> )
Contents |
Description
Join an array into a string with an optional separator.
Parameters
array
The array to join.
separator
Optional; A string to place between each array element.
Default is " " a space.
Return Value
Success - The array merged into a string.
Failure - Returns an empty string.
Remarks
This does not alter the original array.
Example
$days = Array ("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"); Foreach ( $days as $day ) { println("Element is: " . $day); } println("Joined together is " . join($days, ":") ); // Prints: Joined together is Sun:Mon:Tue:Wed:Thu:Fri:Sat