structFind

Determines the value associated with a key in a structure.

structFind(structure, key [, defaultValue ]) → returns any

Member Function Syntax

struct.find(key [, defaultValue ])

structFind Argument Reference

structure struct
Required

Structure that contains the value to return

key string
Required

Key whose value to return

defaultValue any

Lucee 4.5+ Default value which will be returned if the key does not exist or if null was found. Currently only supported by Lucee. See http://docs.lucee.org/reference/functions/structfind.html#argument-defaultValue

Examples sample code invoking the structFind function

Searches through a structure by a given key and outputs the related value

countries = {
    "USA"="Washington D.C.",
    "Germany"="Berlin",
    "Japan"="Tokio"
};
writeOutput(structFind(countries, "Germany"));

Expected Result: Berlin


Fork me on GitHub