Searches recursively through a substructure of nested arrays, structures, and other elements for structures with values that match the search key in the value parameter.
An array that contains structures keys whose values match the search key value. If none are found, returns an array of size 0.
StructFindValue( struct, value [, scope])
Structure functions; Structure functions in the Developing ColdFusion Applications
Parameter |
Description |
|---|---|
struct |
ColdFusion structure from which to start search . This parameter requires an object, not a name of an object. |
value |
String or a variable that contains one for which to search. The type must be a simple object. Arrays and structures are not supported. |
scope |
|
The fields of each structure in the returned array are:
<cfscript>
myStruct=StructNew();// Create struct myStruct
myStruct={a=2,b=4,c=8,d=10,e=12,f=12};// Define keys in myStruct
myStruct.mySecondStruct=StructNew(); //Create nested struct mySecondStruct
myStruct.mySecondStruct.a1=50;//Define keys in mySecondStruct
myStruct.mySecondStruct.a2=12;
myStruct.mySecondStruct.myThirdStruct=StructNew();// Create another nested struct myThirdStruct
myStruct.mySecondStruct.myThirdStruct.b1=12;//Define keys in myThirdStruct
myStruct.mySecondStruct.myThirdStruct.b2=65;
myValue=StructFindValue(myStruct,"12","one");//Search for one default occurrence of "12" in the structs and return appropriate key
WriteDump(myValue);
</cfscript>
<cfscript>
myStruct=StructNew();// Create struct myStruct
myStruct={a=2,b=4,c=8,d=10,e=12,f=12};// Define keys in myStruct
myStruct.mySecondStruct=StructNew(); //Create nested struct mySecondStruct
myStruct.mySecondStruct.a1=50;//Define keys in mySecondStruct
myStruct.mySecondStruct.a2=12;
myStruct.mySecondStruct.myThirdStruct=StructNew();// Create another nested struct myThirdStruct
myStruct.mySecondStruct.myThirdStruct.b1=12;//Define keys in myThirdStruct
myStruct.mySecondStruct.myThirdStruct.b2=65;
myValue=StructFindValue(myStruct,"12","all");//Search all occurrences of "12" in the structs and return appropriate key
WriteDump(myValue);
</cfscript>
Sign in to your account