mirror of
https://github.com/yiisoft/yii2.git
synced 2026-03-14 03:07:53 +01:00
Fix #20268: Minor optimisation in \yii\helpers\BaseArrayHelper::map
This commit is contained in:
committed by
GitHub
parent
25059c4e08
commit
e4d5d73490
@@ -595,6 +595,9 @@ class BaseArrayHelper
|
||||
*/
|
||||
public static function map($array, $from, $to, $group = null)
|
||||
{
|
||||
if (is_string($from) && is_string($to) && $group === null && strpos($from, '.') === false && strpos($to, '.') === false) {
|
||||
return array_column($array, $to, $from);
|
||||
}
|
||||
$result = [];
|
||||
foreach ($array as $element) {
|
||||
$key = static::getValue($element, $from);
|
||||
|
||||
Reference in New Issue
Block a user