Copy link to clipboard
Copied
Trying to use the ArrayFindNoCase function, but it doesnt appear to work on multidimensional arrays? i.e. only on single dimensioned array? can anyone confirm this is the case?
Copy link to clipboard
Copied
I am seeing the same thing. Shame that this post has over 200 views, but no one has an answer.
I am guessing "no" because every example I have Googled has only one dimension. Looks like creating a 'fake' query from scratch is the only way to search a multidimensional recordset.
Copy link to clipboard
Copied
I think the disconnect you are having here is that you think CFML has multi-dimensional arrays: it doesn't. All it has is arrays that can, themselves, have element values that are also arrays (and so forth).
So array functions don't operate on multi-dimensional arrays because there's no such thing in CFML.
The arrayNew() function is a bit misleading because it claims it creates multidimensional arrays, but it doesn't really. For all intents and purposes arrayNew(3) does the same thing as arrayNew(1): creates an empty array.
If you have this array:
numbers = [
[1,2,3,4],
["tahi","rua","toru","wha"],
["one","two","three","four"]
];
You cannot use arrayFInd() on the numbers array to find "tahi", but you could use arrayFind() on numbers[1]. This is no help if you don't know which "sub array" the thing you're finding is in.
TBH, there's seldom requirement in business type code for multi-dimensional arrays, and where people do use them, they really ought to be using arrays of structs, or arrays of objects, or similar. What's your data structure here? I ask because one can use structFindValue() to find values in structs irrespective of the complexity of said struct.
--
Adam