StructKeyList

Get keys of a struct as a string list

Method Signature

StructKeyList(structure=[structloose], delimiter=[string])

Arguments

Argument
Type
Required
Description
Default

structure

struct

true

delimiter

string

false

,

Examples

Using Custom Delimiter

Retrieve a pipe separated list of keys

Run Example

statusCodes = { 
	OK : 200,
	CREATED : 201,
	NOT_MODIFIED : 304,
	BAD_REQUEST : 400,
	NOT_FOUND : 404
};
writeDump( structKeyList( statusCodes, " | " ) );

Result: "OK | CREATED | NOT_MODIFIED | BAD_REQUEST | NOT_FOUND"

Using Member Function

Retrieve a comma separated list of keys using the member function

Run Example

statusCodes = { 
	OK : 200,
	CREATED : 201,
	NOT_MODIFIED : 304,
	BAD_REQUEST : 400,
	NOT_FOUND : 404
};
writeDump( statusCodes.keyList() );

Result: "OK,CREATED,NOT_MODIFIED,BAD_REQUEST,NOT_FOUND"

Additional Examples

Run Example

animals = { 
	COW : "moo",
	PIG : "oink",
	CAT : "meow",
	BIRD : "chirp"
};
// StructKeyList(animals)
animalList = StructKeyList( animals );
echo( animalList );

Last updated

Was this helpful?