>lets say we have 650 elements in our list. >split them into seperate lists with a maximun of 100 elements. > >remember, each list must be in a variable
Here we go - InputList will be your 650 elements. SegmentedLists is an array of the results. <cfset SegmentedLists = segmentList( InputList , 100 ) /> <cfdump var=#SegmentedLists#/> <cffunction name="segmentList" returntype="Array" output="false"> <cfargument name="List" type="String" /> <cfargument name="ItemsPerList" type="Numeric" /> <cfset var MyLists = ArrayNew(1) /> <cfset var CurList = 1 /> <cfset var CurItem = 0 /> <cfset MyLists[1] = ArrayNew(1)/> <cfloop index="CurItem" array="#ListToArray(Arguments.List)#"> <cfif ArrayLen(MyLists[CurList]) GTE Arguments.ItemsPerList > <cfset MyLists[++CurList] = ArrayNew(1) /> </cfif> <cfset ArrayAppend(MyLists[CurList],CurItem) /> </cfloop> <cfloop index="CurList" from="1" to="#ArrayLen(MyLists)#"> <cfset MyLists[CurList] = ArrayToList(MyLists[CurList]) /> </cfloop> <cfreturn MyLists /> </cffunction> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:327171 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4