arrays - 将数组附加到数组

我正在尝试将数组中的元素附加到现有(空)数组

if(attributes.list != "")           attributes.array.append(attributes.list.ListToArray());

我得到的是这样的

有没有一种方法可以做到这一点而不必太循环遍历每个项目?

最佳答案

使用 optional merge parameter :

If set to true, and value parameter is an array, appends array elements individually to the source array. If false (default) the complete array is added as one element at the end, in the source array. If value is not an array this argument is ignored.

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

attributes.array.append(attributes.list.ListToArray(), true);

https://stackoverflow.com/questions/33931995/

相关文章:

rx-java - 将热 Observable 转换为冷 Observable

python - 如何在python中为字符串添加前缀和后缀

php - 使用 Prestashop 1.6 在模块中获取产品类别名称

solr - 使用身份验证在控制台中创建 Solr 核心

java - 当新阶段弹出时,我如何禁用初级阶段

css - 输入内的响应式 fa-icon

cordova - react 路由器和 Cordova 不工作

c# - wpf - Expander 的标题适合内容宽度?

c# - 还有其他更好的方法可以将参数传递给 backgroundworker runasync 吗

php - 编译PHP7错误