Fix #20268: Minor optimisation in \yii\helpers\BaseArrayHelper::map

This commit is contained in:
Christina Reichel
2024-10-27 11:37:09 +01:00
committed by GitHub
parent 25059c4e08
commit e4d5d73490
4 changed files with 75 additions and 15 deletions

View File

@@ -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);