Core Function StrNew
From Sputnik Wiki
(Difference between revisions)
Line 33: | Line 33: | ||
$Str = StrNew('T', 15); | $Str = StrNew('T', 15); | ||
$Str[0] = 'A'; // Set first char to A | $Str[0] = 'A'; // Set first char to A | ||
− | $Str[1] = ' | + | $Str[1] = 'B'; // Set second char to B |
echo $Str; // Prints: ABTTTTTTTTTTTTT | echo $Str; // Prints: ABTTTTTTTTTTTTT | ||
// Of course you could just make the string like | // Of course you could just make the string like | ||
Line 39: | Line 39: | ||
// OR | // OR | ||
// $Str = "AB" . ('T' x 13); | // $Str = "AB" . ('T' x 13); | ||
− | |||
− | |||
</syntaxhighlight> | </syntaxhighlight> | ||
[[Category:Core Function]] | [[Category:Core Function]] |
Revision as of 10:00, 19 September 2015
StrNew( <char>, <length> )
Contents |
Description
Create a new string of a given length filled with a given char.
Parameters
char
What char should populate the new string.
length
How big the new string should be.
Return Value
Success: The new string.
Failure: null
Remarks
None.
Example
Normal string
$Str = StrNew('T', 15); $Str[0] = 'A'; // Set first char to A $Str[1] = 'B'; // Set second char to B echo $Str; // Prints: ABTTTTTTTTTTTTT // Of course you could just make the string like // $Str = "ABTTTTTTTTTTTTT"; // OR // $Str = "AB" . ('T' x 13);