structFind

Determines the value associated with a key in a structure.

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

Member Function Syntax

struct.find(key [, defaultValue ])

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 https://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

Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.

Fork me on GitHub