将数组附加到数组

Jam*_*ler 1 arrays coldfusion coldfusion-11

我试图将数组中的元素追加到现有(空)数组

if(attributes.list != "")           attributes.array.append(attributes.list.ListToArray());
Run Code Online (Sandbox Code Playgroud)

我得到的是类似的东西

在此输入图像描述

有没有办法做到这一点,而没有过多循环每个项目?

Lei*_*igh 8

使用可选merge参数:

如果设置为true,并且value参数是数组,则将数组元素分别附加到源数组.如果为false(默认),则在源数组中将完整数组添加为结尾的一个元素.如果value不是数组,则忽略此参数.

设置merge=true将单独追加元素,而是将整个数组作为单个元素追加:

attributes.array.append(attributes.list.ListToArray(), true);
Run Code Online (Sandbox Code Playgroud)

ArrayAppend(array,merge)示例