Core Function Insert

From Sputnik Wiki
(Difference between revisions)
Jump to: navigation, search
(Created page with "<pre> Insert( <array>, <id>, <expressions> ) </pre> === Description === Add items to an array at a given location === Parameters === ==== array ==== The array to use. ==== ...")
 
(Example)
Line 39: Line 39:
  
 
insert($array, 0, "Zero");
 
insert($array, 0, "Zero");
insert($array, 2, "Four", "Five");
+
insert($array, 3, "Four", "Five");
  
 
$i = 0;
 
$i = 0;

Revision as of 12:38, 28 January 2013

Insert( <array>, <id>, <expressions> )

Contents

Description

Add items to an array at a given location

Parameters

array

The array to use.

id

Location to insert to.

Note - If location doesnt exist it will be created and the void between arrays end and your new index will be empty strings.

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" );
 
insert($array, 0, "Zero");
insert($array, 3, "Four", "Five");
 
$i = 0;
Foreach ( $array as $i )
{
	println("Element ($i) is: " . $i);
	$i++;
}
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox