3v4l.org

run code in 300+ PHP versions simultaneously
<?php $graphData = array( 'DataArr' => array ( array( 'data' => array ( array ( 'Month' => '10 Jan 2019', 'Cost' => 60.3, 'Name' => 'Savings' ), array ( 'Month' => '10 Feb 2019', 'Cost' => 45.3, 'Name' => 'Savings' ), array ( 'Month' => '10 Mar 2019', 'Cost' => 50.6, 'Name' => 'Savings' ) ) ), array ( 'data' => array ( array ( 'Month' => '10 Jan 2019', 'Cost' => 89.62, 'Name' => 'Discount' ), array ( 'Month' => '10 Feb 2019', 'Cost' => 20.2, 'Name' => 'Discount' ), array ( 'Month' => '10 Mar 2019', 'Cost' => 0.0, 'Name' => 'Discount' ) ) ) ) ); $result = []; foreach($graphData['DataArr'] as $value){ foreach($value['data'] as $details){ if(!isset($result['data'][$details['Month']])) $result['data'][$details['Month']] = ['Month' => $details['Month']]; $result['data'][$details['Month']][$details['Name']] = $details['Cost']; } } $result['data'] = array_values($result['data']); print_r($result);
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [data] => Array ( [0] => Array ( [Month] => 10 Jan 2019 [Savings] => 60.3 [Discount] => 89.62 ) [1] => Array ( [Month] => 10 Feb 2019 [Savings] => 45.3 [Discount] => 20.2 ) [2] => Array ( [Month] => 10 Mar 2019 [Savings] => 50.6 [Discount] => 0 ) ) )

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:
191.17 ms | 407 KiB | 5 Q