Passing a dynamic number of arguments to a ColdFusion function is possible, but the method isn't obvious. ColdFusion provides the argumentCollection attribute, which assists the passing dynamic arguments, but how do we access these argument names dynamically within the function?
The answer lies in the fact that the arguments object is a structure, whose keys are the arguments passed to the function.
The example below may help explain:
<cffunction name="myfunction" access="remote" output="true">
<cfdump var="#arguments#">
<cfoutput>#arguments.param1#</cfoutput>
</cffunction>
Test the output with a GET request:
http://mysite.com/components/mycfc.cfc?method=myfunction&ReturnFormat=json¶m1=test
Notice that we haven't defined any arguments using <cfargument>. Yet, we are able to access these by referencing the arguments structure's keys.