Raj KAJ (scottobear) wrote,
Raj KAJ
scottobear

cf method to merge a list and array

Pretty self explanatory:

/**
* mergeListToArray
* When provided a list and an array, we convert the list to an array and merge them.
* @param {Array} a Array to merge list to {required}
* @param {String} l List to merge with array {required}
* @param {String} delim Delimiters to use default = ','
* @return {Array}
*/
public Array function mergeListToArray(required array a,required string l,required string delim=','){
var tmpArr = ListToArray(trim(arguments.l),delim);
var newArr = arguments.a;
if(IsArray(newArr) && IsArray(tmpArr)){
// loop over current array and append to new array
for(i=1; i LTE ArrayLen(tmpArr); i=(i+1)){
ArrayAppend(newArr,tmpArr[i]);
}//end loop
}//end isarray
return newArr;
};

Originally published at The Scotto Grotto. You can comment here or there.

Tags: code
Subscribe
  • Post a new comment

    Error

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 0 comments