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);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 29
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 29
Branch analysis from position: 5
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 27
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 27
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 19
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 19
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 27
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
filename:       /in/QMVuR
function name:  (null)
number of ops:  40
compiled vars:  !0 = $graphData, !1 = $result, !2 = $value, !3 = $details
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   59     1        ASSIGN                                                   !1, <array>
   61     2        FETCH_DIM_R                                      ~6      !0, 'DataArr'
          3      > FE_RESET_R                                       $7      ~6, ->29
          4    > > FE_FETCH_R                                               $7, !2, ->29
   62     5    >   FETCH_DIM_R                                      ~8      !2, 'data'
          6      > FE_RESET_R                                       $9      ~8, ->27
          7    > > FE_FETCH_R                                               $9, !3, ->27
   63     8    >   FETCH_DIM_R                                      ~11     !3, 'Month'
          9        FETCH_DIM_IS                                     ~10     !1, 'data'
         10        ISSET_ISEMPTY_DIM_OBJ                         0  ~12     ~10, ~11
         11        BOOL_NOT                                         ~13     ~12
         12      > JMPZ                                                     ~13, ->19
         13    >   FETCH_DIM_R                                      ~15     !3, 'Month'
         14        FETCH_DIM_R                                      ~17     !3, 'Month'
         15        INIT_ARRAY                                       ~18     ~17, 'Month'
         16        FETCH_DIM_W                                      $14     !1, 'data'
         17        ASSIGN_DIM                                               $14, ~15
         18        OP_DATA                                                  ~18
   64    19    >   FETCH_DIM_R                                      ~20     !3, 'Month'
         20        FETCH_DIM_R                                      ~22     !3, 'Name'
         21        FETCH_DIM_R                                      ~24     !3, 'Cost'
         22        FETCH_DIM_W                                      $19     !1, 'data'
         23        FETCH_DIM_W                                      $21     $19, ~20
         24        ASSIGN_DIM                                               $21, ~22
         25        OP_DATA                                                  ~24
   62    26      > JMP                                                      ->7
         27    >   FE_FREE                                                  $9
   61    28      > JMP                                                      ->4
         29    >   FE_FREE                                                  $7
   68    30        INIT_FCALL                                               'array_values'
         31        FETCH_DIM_R                                      ~26     !1, 'data'
         32        SEND_VAL                                                 ~26
         33        DO_ICALL                                         $27     
         34        ASSIGN_DIM                                               !1, 'data'
         35        OP_DATA                                                  $27
   69    36        INIT_FCALL                                               'print_r'
         37        SEND_VAR                                                 !1
         38        DO_ICALL                                                 
         39      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
144.27 ms | 1016 KiB | 15 Q