Core Function Unshift
From Sputnik Wiki
(Difference between revisions)
(Created page with "<pre> Unshift( <array>, <expressions> ) </pre> === Description === Add items to the beginning of an array === Parameters === ==== array ==== The array to use. === Return Va...") |
|||
Line 12: | Line 12: | ||
The array to use. | The array to use. | ||
+ | |||
+ | ==== expressions ==== | ||
+ | |||
+ | One or more values to add to the array. | ||
=== Return Value === | === Return Value === |
Revision as of 12:17, 29 November 2011
Unshift( <array>, <expressions> )
Contents |
Description
Add items to the beginning of an array
Parameters
array
The array to use.
expressions
One or more values to add to the array.
Return Value
Success - Returns how many elements were done.
Failure - Returns 0.
Remarks
None
Example
$array = array ( "Two", "Three" ); unshift($array, "One"); unshift($array, "Zero", "Oh my!"); $i = 0; Foreach ( $array as $i ) { println("Element ($i) is: " . $i); $i++; }
Alternative method using the ..= operator
$array = array ( "Two", "Three" ); $array ..= array("One"); $array ..= array("Zero", "Oh my!"); $i = 0; Foreach ( $array as $i ) { println("Element ($i) is: " . $i); $i++; }