Tutorial

Getting Started with Macros

Macro Editor

User Interface

Menus and Toolbar

Editing Macros

Macro Debugging

How To

Using variables

Finding and modifying objects

Creating new page content

Asking for user input

Storing persistent data

Using binary data

Sorting objects

Macro menus

Bulleted and numbered lists

Sample Macros

Concepts

Expressions

Objects

Properties

Variables

Data Types

Arrays

Functions

Literals

Operators

Comments

Last updated on: September 02, 2024
Also available as a single HTML file

Onetastic Macro Documentation > Functions > Array Functions > Array_FlipKeysAndValues

Array_FlipKeysAndValues

Exchanges the keys and their associated values in the given array. The values must be numeric or string since they will now become keys.

Syntax

void Array_FlipKeysAndValues(byref Array array)

Parameters

Array array
Array to flip keys and values.

Examples

$array = Array("red", "green", "blue", 5) // This created the following array // 0 => "red" // 1 => "green" // 2 => "blue" // 3 => 5 Array_FlipKeysAndValues($array) // Now we have the following keys and values: // "red" => 0 // "green" => 1 // "blue" => 2 // 5 => 3 // If the values aren't string or numeric, // flipping keys and values will result in an error $array = Array(GetCurrentPage(), GetCurrentSection()) Array_FlipKeysAndValues($array) // Error: Cannot convert expression of type Object to an expression of type String // If the values aren't unique, latter values will write over former ones $array = Array(3, 5, 8, 5, 2, 3) // This created the following array // 0 => 3, 1 => 5, 2 => 8, 3 => 5, 4 => 2, 5 => 3 Array_FlipKeysAndValues($array) // Now we have the following keys and values: // 3 => 5, 5 => 3, 8 => 2, 2 => 4

Reference

Statements

Hierarchy Objects

Page Objects

Other Objects

Functions

Array Functions

Color Functions

Data Store Functions

Date/Time Functions

Dialog Box Functions

Macro Execution Functions

Macro Menu Functions

Object Functions

Special Functions

String Functions

Window Functions