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_ValueExists

Array_ValueExists

Returns whether a given value exists or not in the given array. A variable is passed to the last parameter to retrieve the key associated with the value if exists.

Syntax

Bool Array_ValueExists(
	Array array, 
	Mixed value, 
	out Mixed key)

Parameters

Array array
Array to look for the value in.
Mixed value
Value to look for.
out Mixed key
If the value is found, the key is stored in this variable. If the value appears more than once in the array first found key is returned.

Examples

$array = Array(2, 4, 6, "apple", "banana", "strawberry", 4, 2) $foundBanana = Array_ValueExists($array, "banana", $key) // $foundBanana is true, $key is 4 $found4 = Array_ValueExists($array, 4, $key) // $found4 is true, $key is 1 $found5 = Array_ValueExists($array, 5, $key) // $found5 is false, $key is not modified

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