Skip to content

Commit 4a283d4

Browse files
committed
MAGE-1383 Experiment with array_walk alternative
1 parent 3ea6790 commit 4a283d4

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

Helper/ArrayDeduplicator.php

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,18 @@ public function dedupeArrayOfArrays(array $data): array {
4040
// $unique
4141
// );
4242
// Experiment 1
43-
$decoded = array_map(
44-
'json_decode',
45-
$unique,
46-
array_fill(0, count($unique), true) // force decoding as associative array
47-
);
43+
// $decoded = array_map(
44+
// 'json_decode',
45+
// $unique,
46+
// array_fill(0, count($unique), true) // force decoding as associative array
47+
// );
48+
49+
// Experiment 2
50+
$decoded = [];
51+
array_walk($unique, function($item) use (&$decoded) {
52+
$decoded[] = json_decode((string) $item, true);
53+
});
54+
4855
return $decoded;
4956
}
5057
}

0 commit comments

Comments
 (0)