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 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.27, 8.4.1 - 8.4.14, 8.5.0 - 8.5.1
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 ) ) )
Output for 8.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.
Output for 8.3.28
/bin/php-8.3.28: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.3.28) /bin/php-8.3.28: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.3.28) /bin/php-8.3.28: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.3.28) /bin/php-8.3.28: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.3.28)
Process exited with code 1.

preferences:
185.9 ms | 408 KiB | 5 Q