Core Function Repeat

From Sputnik Wiki
Jump to: navigation, search
Repeat( <expression>, <count>, <flag> )

Contents

Description

Create a new string or new array containing repeats of a string provided.

Parameters

expression

The string to copy.

count

The amount of times to copy the string

flag

Optional; If the flag is higher than one it will return an array instead of a string.

Default 0 returns a string.

Return Value

Returns new string or new array.

Remarks

None.

Example

println(      Repeat("AA", 3)      ); // Prints AAAAAA
 
Foreach( Repeat("AA", 3, 1) as $i )
{
	println( $i ); // Prints "AA" 3 times
}

Alternative method using the "x" repetition operator

println(    "AA" x 3      ); // Prints AAAAAA
 
Foreach( array("AA") x 3 as $i )
{
	println( $i ); // Prints "AA" 3 times
}
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox