View comments | RSS feed
Contents > CFML Reference > ColdFusion Functions > Functions by category > Array functions PreviousNext

Array functions

ArrayAppend

ArrayIsEmpty

ArrayPrepend

ArraySwap

ArrayAvg

ArrayLen

ArrayResize

ArrayToList

ArrayClear

ArrayMax

ArraySet

IsArray

ArrayDeleteAt

ArrayMin

ArraySort

ListToArray

ArrayInsertAt

ArrayNew

ArraySum

 


Contents > CFML Reference > ColdFusion Functions > Functions by category > Array functions PreviousNext

ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | Bug Reporting

Version 6.1

Comments are no longer accepted for ColdFusion MX 6.1. ColdFusion 8 is the current version.

Comments


cfmx_nitin said on Jul 9, 2004 at 4:42 AM :
1. Is there any function available to create a key-value pair in a 2D array?
2. Is there any function available to retrieve values from 2D array in the form of key-value pairs?
halL said on Jul 9, 2004 at 7:47 AM :
ColdFusion MX does not provide the functions described by cfmx_nitin.
ColdFusion MX Structures support Key-value pairs.
For more information on using structures and arrays in ColdFusion, see http://livedocs.macromedia.com/coldfusion/6.1/htmldocs/arraystr.htm.
If you need additional assistance that is not available in the documentation, consider posting your issue to the online forums: http://webforums.macromedia.com/coldfusion/.
kechrek said on Jul 13, 2004 at 12:13 PM :
how would I perform a seach in an array...for example, lists have Find(), ListFind(), etc, how could I do something similar with arrays
bubblocity said on Jul 21, 2004 at 4:41 AM :
Try the following:

<cffunction name="ArrayFind" returntype="boolean">
<cfargument name="Needle" required="true">
<cfargument name="HayStack" required="true">
<cfset var Found=false>

<cfif isArray(arguments.HayStack)>
<cfloop index="i" from="1" to="#ArrayLen(arguments.HayStack)#">
<cfif arguments.Needle IS arguments.Haystack[i]>
<cfset Found = true>
<cfbreak>
</cfif>
</cfloop>
</cfif>
<cfreturn Found>
</cffunction>
<cffunction name="ArrayFindNoCase" returntype="boolean">
<cfargument name="Needle" required="true">
<cfargument name="HayStack" required="true">
<cfset var Found=false>

<cfif isArray(arguments.HayStack)>
<cfloop index="i" from="1" to="#ArrayLen(arguments.HayStack)#">
<cfif UCase(arguments.Needle) EQ UCase(arguments.Haystack[i])>
<cfset Found = true>
<cfbreak>
</cfif>
</cfloop>
</cfif>
<cfreturn Found>
</cffunction>
jjs4775 said on Sep 20, 2004 at 8:41 AM :
another way to search an erray...

<cfscript>
/**
* UDF searches for a value within an array
* like listFind(), except with an array
*
* takes 2 paramaters... arrayToSearch, valueToFind (both required)
* returns a numeric result
*/
function arrayFind(arrayToSearch,valueToFind){
//looping variable
var ii = 0;
//loop through the array, looking for the valueToFind
for(ii = 1; ii LTE arrayLen(arrayToSearch); ii = ii + 1){
//if the value is found, return the index
if(NOT compare(arrayToSearch[ii][1],valueToFind))
return ii;
}
//if we've goten this far, it means the value was not found, so return 0
return 0;
}
</cfscript>
No screen name said on Feb 27, 2005 at 1:46 PM :
Is there any way to sort 2D array?
ASandstrom said on Aug 23, 2005 at 6:22 AM :
There's an article on sorting multi-dimensional arrays in the ColdFusion Developer's Journal, here: http://coldfusion.sys-con.com/read/42070.htm.
No screen name said on Nov 21, 2005 at 2:05 PM :
It should be noted in the example above, IS performs a case-insesative compare. So both functions are case insensative.

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/coldfusion/6.1/htmldocs/functio3.htm