Tutorial

Getting Started with Macros

Macro Editor

User Interface

Menus and Toolbar

Editing Macro Statements

Expression Editor

Macro Debugging

How To

Using variables

Finding and modifying objects

Creating new page content

Asking for user input

Storing persistent data

Sorting objects

Sample Macros

Concepts

Expressions

Objects

Properties

Variables

Data Types

Arrays

Functions

Literals

Operators

Comments

Last updated on: April 17, 2021
Also available as a single HTML file

Onetastic Macro Documentation > Functions > Array Functions > Array_PushFront

Array_PushFront

Inserts the given value to the beginning of the array. All numerical keys in the array will be modified to start counting from zero while string keys won't be affected. Returns the number of elements in the array after the insertion.

Syntax

Numeric Array_PushFront(
	Array array, 
	Mixed value)

Parameters

Array array
Array to insert the value to.
Mixed value
The value to insert.

Examples

$array = Array(6, 4, 8) $sizeAfterFirstPushFront = Array_PushFront($array, 3) $sizeAfterSecondPushFront = Array_PushFront($array, 7) // $array is now (7, 3, 6, 4, 8) // $sizeAfterFirstPushFront is 4 // $sizeAfterSecondPushFront is 5 // You can create an array with Array_PushFront Array_PushFront($array2, 5) // $array2 is now (5) Array_PushFront($array2, 7) // $array2 is now (7, 5) // Numeric keys will reset to start from 0 $array3[5] = 10 $array3[7] = 12 Array_PushFront($array3, 8) // $array3 is now: // 0 => 8 // 1 => 10 // 2 => 12 Array_PushFront($array3, 6) // $array3 is now: // 0 => 6 // 1 => 8 // 2 => 10 // 3 => 12 // String keys are not affected: $array4["size"] = "large" $array4[7] = "a" $array4[-2] = "b" $array4["color"] = "red" Array_PushFront($array4, "t-shirt") Array_PushFront($array4, 10) Array_PushFront($array4, 5) // $array4 is now: // 0 => 5 // 1 => 10 // 2 => "t-shirt" // "size" => "large" // 3 => "a" // 4 => "b" // "color" => "red"

Reference

Statements

For

ForEach

If

Else If

Else

Switch

Case

Default

While

Expression

Comment

Break

Continue

Return

Hierarchy Objects

NotebookRoot

Notebook

SectionGroup

Section

Page

Page Objects

Title

Outline

Table

Column

Row

Cell

Paragraph

Text

Image

EmbeddedFile

Tag

Other Objects

DialogBox

Functions

Array Functions

Color Functions

Data Store Functions

Date/Time Functions

Dialog Box Functions

Macro Execution Functions

Object Functions

String Functions