> Im trying to do some stuff to an old farcry 3 custom admin tool that I > did a while back. > > Basically, Ive got 2 x 1 dimensional arrays - lets call them > "listOne", and "listTwo" > > listOne has about 1000 names inside > listTwo has a selection of 200 of those 1000 names > > What Im trying to do is compare the two arrays, and create a 3rd array > "listThree" which is basically the result of removing items in listTwo > from listOne > > To illustrate: > > listOne = "andy, bob, jim, craig, steven" > listTwo = "bob,jim" > > listThree ="andy,craig,steven" > > Any idea on how I can go about doing this ? > > Ive tried looping through and all sorts, but just havnt hacked it yet > (its monday,and Im still recovering from weekend celebrations!)
Baz, I don't remember where I found this custom function, but for a while now I've been using a function called ListInListFind() (not written by me). A quick Google search found a copy here: http://www.mximize.com/find-item-in-list2-from-list1-list-to-list-compare- (maybe he is the original author). I rewrote it a long time back to be a cffunction (below). Hope this helps! (note: You may or may-not want to change the listFindNoCase to case sensitive). ======= <cffunction name="listInListFind" returntype="string" access="public" output="false" hint="Returns the first match found in list1 compared to list2. Returns 0 if no match."> <cfargument name="list1" type="string" hint="A list" required="true" /> <cfargument name="list2" type="string" hint="A list" required="true" /> <cfargument name="delimiters" type="String" hint="Delimiter(s) used for the lists." required="false" default="," /> <cfset var i = '' /> <cfset var returnVar = 0 /> <cfloop index="i" list="#arguments.list1#" delimiters="#arguments.delimiters#"> <cfif listFindNoCase(arguments.list2, i, arguments.delimiters)> <cfset returnVar = i /> <cfbreak /> </cfif> </cfloop> <cfreturn returnVar /> </cffunction> ======= Regards, -- Jeff Coughlin Web Application Developer http://jeffcoughlin.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "farcry-dev" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/farcry-dev?hl=en -~----------~----~----~----~------~----~------~--~---
