Core Function Push
From Sputnik Wiki
(Difference between revisions)
(Created page with "<pre> Push( <array>, <expressions> ) </pre> === Description === Add items to the end of an array === Parameters === ==== array ==== The array to use. === Return Value === ...") |
(→Example) |
||
Line 30: | Line 30: | ||
push($array, "Three"); | push($array, "Three"); | ||
push($array, "Four", "Five"); | push($array, "Four", "Five"); | ||
+ | |||
+ | $i = 0; | ||
+ | Foreach ( $array as $i ) | ||
+ | { | ||
+ | println("Element ($i) is: " . $i); | ||
+ | $i++; | ||
+ | } | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | Alternative method using the ..= operator | ||
+ | |||
+ | <syntaxhighlight lang="sputnik"> | ||
+ | $array = array ( "One", "Two" ); | ||
+ | |||
+ | $array .= array("Three"); | ||
+ | $array .= array("Four", "Five"); | ||
$i = 0; | $i = 0; |
Revision as of 12:15, 29 November 2011
Push( <array>, <expressions> )
Contents |
Description
Add items to the end of an array
Parameters
array
The array to use.
Return Value
Success - Returns how many elements were done.
Failure - Returns 0.
Remarks
None
Example
$array = array ( "One", "Two" ); push($array, "Three"); push($array, "Four", "Five"); $i = 0; Foreach ( $array as $i ) { println("Element ($i) is: " . $i); $i++; }
Alternative method using the ..= operator
$array = array ( "One", "Two" ); $array .= array("Three"); $array .= array("Four", "Five"); $i = 0; Foreach ( $array as $i ) { println("Element ($i) is: " . $i); $i++; }