3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $data = Array ( 0 => Array ( 'entry_id' => 1, 'ic' => 2147483647, 'name' => 'Kořínková Blanka', 'residency' => 'Štětí, Lukešova 354, 411 08', 'file_no' => 'KSUL 77 INS 18898 / 2013', 'detail' => '749371da-725c-4738-8def-2f7167142a6f' ), 1 => Array ( 'entry_id' => 1, 'ic' => 2147483647, 'name' => 'Kořínková Blanka', 'residency' => 'Štětí, Lukešova 354, 411 08', 'file_no' => 'KSUL 77 INS 21218 / 2013', 'detail' => '43b6a718-4647-451d-9c53-50dfee8403ff' ), 2 => Array ( 'entry_id' => 2, 'ic' => 46900217, 'name' => 'ENTEC a.s. "v likvidaci"', 'residency' => 'Staré Město, Brněnská 1916, 686 03', 'file_no' => 'KSBR 28 INS 1232 / 2013', 'detail' => 'e2155a52-c464-4357-b71b-4f4ff75585eb' ) ); $mergeId = 'entry_id'; $data = array_reduce($data, function($c, $x) use ($mergeId) { $c[$x[$mergeId]] = isset($c[$x[$mergeId]]) ?array_combine( $z=array_keys($c[$x[$mergeId]]), array_map(function($y) use ($x, $c, $mergeId) { return in_array($x[$y], (array)$c[$x[$mergeId]][$y]) ?$c[$x[$mergeId]][$y] :array_merge((array)$c[$x[$mergeId]][$y], [$x[$y]]); }, $z) ) :$x; return $c; }, []); var_dump($data);
Output for 5.4.0 - 7.1.0
array(2) { [1]=> array(6) { ["entry_id"]=> int(1) ["ic"]=> int(2147483647) ["name"]=> string(19) "Kořínková Blanka" ["residency"]=> string(31) "Štětí, Lukešova 354, 411 08" ["file_no"]=> array(2) { [0]=> string(24) "KSUL 77 INS 18898 / 2013" [1]=> string(24) "KSUL 77 INS 21218 / 2013" } ["detail"]=> array(2) { [0]=> string(36) "749371da-725c-4738-8def-2f7167142a6f" [1]=> string(36) "43b6a718-4647-451d-9c53-50dfee8403ff" } } [2]=> array(6) { ["entry_id"]=> int(2) ["ic"]=> int(46900217) ["name"]=> string(24) "ENTEC a.s. "v likvidaci"" ["residency"]=> string(38) "Staré Město, Brněnská 1916, 686 03" ["file_no"]=> string(23) "KSBR 28 INS 1232 / 2013" ["detail"]=> string(36) "e2155a52-c464-4357-b71b-4f4ff75585eb" } }
Output for 5.3.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/4uQCs on line 48
Process exited with code 255.
Output for 5.2.3 - 5.2.17
Parse error: syntax error, unexpected T_FUNCTION in /in/4uQCs on line 39
Process exited with code 255.
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.2.2
<br /> <b>Parse error</b>: syntax error, unexpected T_FUNCTION in <b>/in/4uQCs</b> on line <b>39</b><br />
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
<br /> <b>Parse error</b>: parse error, unexpected T_FUNCTION in <b>/in/4uQCs</b> on line <b>39</b><br />
Process exited with code 255.
Output for 4.3.2 - 4.3.4
<br /> <b>Parse error</b>: parse error in <b>/in/4uQCs</b> on line <b>39</b><br />
Process exited with code 255.