We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 337e0e8 commit c09a0fdCopy full SHA for c09a0fd
1 file changed
src/Illuminate/Support/Collection.php
@@ -884,16 +884,19 @@ public function mapToDictionary(callable $callback)
884
{
885
$dictionary = [];
886
887
- $this->each(function ($item, $key) use (&$dictionary, $callback) {
+ foreach ($this->items as $key => $item) {
888
$pair = $callback($item, $key);
889
+
890
$key = key($pair);
891
892
$value = reset($pair);
893
894
if (! isset($dictionary[$key])) {
895
$dictionary[$key] = [];
896
}
897
898
$dictionary[$key][] = $value;
- });
899
+ }
900
901
return new static($dictionary);
902
0 commit comments