structKeyArray

Returns the keys in a CFML structure as an array. If structure does not exist throws an exception.

structKeyArray(structure) → returns array

Member Function Syntax

someStruct.keyArray()

Argument Reference

structure struct
Required

Examples
Sample code invoking the structKeyArray function

statusCodes = {
    OK = 200,
    CREATED = 201,
    NOT_MODIFIED = 304,
    BAD_REQUEST = 400,
    NOT_FOUND = 404
};

writeDump(structKeyArray(statusCodes));

Expected Result: [NOT_FOUND, BAD_REQUEST, CREATED, OK, NOT_MODIFIED]

CF 11+ Lucee 4.5+ Retrieve a comma separated list of keys using the member function

statusCodes = {
    OK = 200,
    CREATED = 201,
    NOT_MODIFIED = 304,
    BAD_REQUEST = 400,
    NOT_FOUND = 404
};

writeDump(statusCodes.keyArray());

Expected Result: [NOT_FOUND, BAD_REQUEST, CREATED, OK, NOT_MODIFIED]

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

Fork me on GitHub