Yii2: ArrayHelper::merge() gives duplicated for integer key values

Created on 18 May 2017  路  4Comments  路  Source: yiisoft/yii2

If each array has an element with the same string key value, the latter will overwrite the former (different from array_merge_recursive).

however, merging this to array twice
["pluginOptions" => ["allowedFileTypes" => ["image"]]]
will give
["pluginOptions" => ["allowedFileTypes" => [0 => "image", 1 => "image"]]]

Shouldn't these values overriden? It would be usefull in merging config arrays for widgets

question

Most helpful comment

All 4 comments

This is expected behavior.

Thank you for your question.
In order for this issue tracker to be effective, it should only contain bug reports and feature requests.

We advise you to use our community driven resources:

If you are confident that there is a bug in the framework, feel free to provide information on how to reproduce it. This issue will be closed for now.

_This is an automated comment, triggered by adding the label question._

Yes i know that it works for string key, i qouted the documentation that says that

I am suggesting to make it possible to override duplicate values too, we are using this method extensivly with merging config arrays, having this ability in this method would be helpful

Was this page helpful?
0 / 5 - 0 ratings