structCount

Counts the keys in a structure.

structCount(structure) → returns numeric

Argument Reference

structure struct
Required

Structure to access

Examples
Sample code invoking the structCount function

Pass a structure as an argument to the function.

user = {
    id = 1,
    firstname = "Han",
    lastname = "Solo",
    movie = "Star Wars"
};

writeDump( structCount( user ) );

Expected Result: 4

CF 11+ Lucee 4.5+ Having a reference of a structure as a variable, use the dot notation to get a key count on it using a member function.

user = {
    id = 1,
    firstname = "Han",
    lastname = "Solo",
    movie = "Star Wars"
};

writeDump( user.count() );

Expected Result: 4

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

Fork me on GitHub