3v4l.org

run code in 500+ PHP versions simultaneously
<?php $companyX = [ 0 => [ 2 => 'company X', 107 => 'Accounts receivable', 2000 => 'Provider A', 'amount' => 2 ], 1 => [ 2 => 'company X', 107 => 'Accounts receivable', 4123 => 'Provider F', 'amount' => 5 ], 2 => [ 2 => 'company X', 205 => 'Accounts payable', 2000 => 'Provider A', 'amount' => 2 ], 3 => [ 2 => 'company X', 205 => 'Accounts payable', 4123 => 'Provider F', 'amount' => 7 ], 4 => [ 2 => 'company X', 603 => 'Sales', 2011 => 'Provider G', 'amount' => 9 ] ]; $companyY = [ 0 => [ 5 => 'company Y', 107 => 'Accounts receivable', 2000 => 'Provider A', 'amount' => 15 ], 1 => [ 5 => 'company Y', 107 => 'Accounts receivable', 4123 => 'Provider F', 'amount' => 21 ], 2 => [ 5 => 'company Y', 205 => 'Accounts payable', 2000 => 'Provider A', 'amount' => 36 ], 3 => [ 5 => 'company Y', 205 => 'Accounts payable', 4123 => 'Provider F', 'amount' => 47 ], 4 => [ 5 => 'company Y', 701 => 'Costs', 6360 => 'Provider K', 'amount' => 14 ] ]; $companyZ = [ 0 => [ 8 => 'company Z', 107 => 'Accounts receivable', 2000 => 'Provider A', 'amount' => 51 ], 1 => [ 8 => 'company Z', 107 => 'Accounts receivable', 4123 => 'Provider F', 'amount' => 63 ], 2 => [ 8 => 'company Z', 205 => 'Accounts payable', 2000 => 'Provider A', 'amount' => 74 ], 3 => [ 8 => 'company Z', 205 => 'Accounts payable', 4123 => 'Provider F', 'amount' => 83 ] ]; $data = [...$companyX, ...$companyY, ...$companyZ]; $grouped = []; foreach($data as $item) { $item = array_values($item); $grouped[$item[1]][$item[2]][$item[0]][] = $item[3]; } print_r($grouped);
Output for rfc.property-hooks, git.master_jit, git.master
Array ( [Accounts receivable] => Array ( [Provider A] => Array ( [company X] => Array ( [0] => 2 ) [company Y] => Array ( [0] => 15 ) [company Z] => Array ( [0] => 51 ) ) [Provider F] => Array ( [company X] => Array ( [0] => 5 ) [company Y] => Array ( [0] => 21 ) [company Z] => Array ( [0] => 63 ) ) ) [Accounts payable] => Array ( [Provider A] => Array ( [company X] => Array ( [0] => 2 ) [company Y] => Array ( [0] => 36 ) [company Z] => Array ( [0] => 74 ) ) [Provider F] => Array ( [company X] => Array ( [0] => 7 ) [company Y] => Array ( [0] => 47 ) [company Z] => Array ( [0] => 83 ) ) ) [Sales] => Array ( [Provider G] => Array ( [company X] => Array ( [0] => 9 ) ) ) [Costs] => Array ( [Provider K] => Array ( [company Y] => Array ( [0] => 14 ) ) ) )

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
56.14 ms | 1289 KiB | 4 Q