We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How do you like the idea of extending the functionality of setValue by adding an append parameter or similar? Example:
$arr = [ 'вот' => [ 'мой' => [ 'ключ' => null, ], ], ]; $result = \Yiisoft\Arrays\ArrayHelper::getValue($arr, ['вот', 'мой', 'ключ'], []); echo $result; // []; \Yiisoft\Arrays\ArrayHelper::setValue($arr, ['вот', 'мой', 'ключ'], 'lol'); \Yiisoft\Arrays\ArrayHelper::setValue($arr, ['вот', 'мой', 'ключ'], 'kek'); $result = \Yiisoft\Arrays\ArrayHelper::getValue($arr, ['вот', 'мой', 'ключ'], []); echo $result; // 'kek';
And adding append
\Yiisoft\Arrays\ArrayHelper::setValue($arr, ['вот', 'мой', 'ключ'], 'lol', append: true); \Yiisoft\Arrays\ArrayHelper::setValue($arr, ['вот', 'мой', 'ключ'], 'kek', append: true); $result = \Yiisoft\Arrays\ArrayHelper::getValue($arr, ['вот', 'мой', 'ключ'], []); echo $result; // ['lol', 'kek'];
If the key does not exist an empty array is initialized.
The text was updated successfully, but these errors were encountered:
Possible to realize this way:
\Yiisoft\Arrays\ArrayHelper::setValue($arr, ['вот', 'мой', 'ключ', null], 'lol'); \Yiisoft\Arrays\ArrayHelper::setValue($arr, ['вот', 'мой', 'ключ', null], 'kek'); $result = \Yiisoft\Arrays\ArrayHelper::getValue($arr, ['вот', 'мой', 'ключ'], []); echo $result; // ['lol', 'kek'];
or
\Yiisoft\Arrays\ArrayHelper::setValue($arr, ['вот', 'мой', 'ключ', []], 'lol'); \Yiisoft\Arrays\ArrayHelper::setValue($arr, ['вот', 'мой', 'ключ', []], 'kek'); $result = \Yiisoft\Arrays\ArrayHelper::getValue($arr, ['вот', 'мой', 'ключ'], []); echo $result; // ['lol', 'kek'];
Sorry, something went wrong.
I think better create new method for this feature. Call it addValue or push...
addValue
push
Done by #137
No branches or pull requests
How do you like the idea of extending the functionality of setValue by adding an append parameter or similar?
Example:
And adding append
If the key does not exist an empty array is initialized.
The text was updated successfully, but these errors were encountered: