3v4l.org

run code in 500+ PHP versions simultaneously
<?php $json = '[ { "StatsHistoryTime": "2019-02-06 12:00:00", "name": "shelly", "hashrate": 2147483647 }, { "StatsHistoryTime": "2019-02-06 12:00:00", "name": "debra", "hashrate": 1240996571 }, { "StatsHistoryTime": "2019-02-06 12:00:00", "name": "sally", "hashrate": 2147483647 }, { "StatsHistoryTime": "2019-02-06 12:00:00", "name": "bill", "hashrate": 2147483647 }, { "StatsHistoryTime": "2019-02-06 12:30:00", "name": "shelly", "hashrate": 2147483647 }, { "StatsHistoryTime": "2019-02-06 12:30:00", "name": "debra", "hashrate": 1460613388 }, { "StatsHistoryTime": "2019-02-06 12:30:00", "name": "sally", "hashrate": 2147483647 }, { "StatsHistoryTime": "2019-02-06 12:30:00", "name": "bill", "hashrate": 2147483647 } ]'; $rows = json_decode($json, true); $chartdata = array(); foreach ($rows as $row) { $period = $row['StatsHistoryTime']; if (($k = array_search($period, array_column($chartdata, 'period'))) !== false) { $chartdata[$k][$row['name']] = $row['hashrate']; } else { $chartdata[] = array('period' => $period, $row['name'] => $row['hashrate']); } } echo json_encode($chartdata);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 35
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 35
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 28
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 34
Branch analysis from position: 34
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 35
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 35
filename:       /in/c3F3p
function name:  (null)
number of ops:  41
compiled vars:  !0 = $json, !1 = $rows, !2 = $chartdata, !3 = $row, !4 = $period, !5 = $k
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                       !0, '%5B%0A++%7B%0A++++%22StatsHistoryTime%22%3A+%222019-02-06+12%3A00%3A00%22%2C%0A++++%22name%22%3A+%22shelly%22%2C%0A++++%22hashrate%22%3A+2147483647%0A++%7D%2C%0A++%7B%0A++++%22StatsHistoryTime%22%3A+%222019-02-06+12%3A00%3A00%22%2C%0A++++%22name%22%3A+%22debra%22%2C%0A++++%22hashrate%22%3A+1240996571%0A++%7D%2C%0A++%7B%0A++++%22StatsHistoryTime%22%3A+%222019-02-06+12%3A00%3A00%22%2C%0A++++%22name%22%3A+%22sally%22%2C%0A++++%22hashrate%22%3A+2147483647%0A++%7D%2C%0A++%7B%0A++++%22StatsHistoryTime%22%3A+%222019-02-06+12%3A00%3A00%22%2C%0A++++%22name%22%3A+%22bill%22%2C%0A++++%22hashrate%22%3A+2147483647%0A++%7D%2C%0A++%7B%0A++++%22StatsHistoryTime%22%3A+%222019-02-06+12%3A30%3A00%22%2C%0A++++%22name%22%3A+%22shelly%22%2C%0A++++%22hashrate%22%3A+2147483647%0A++%7D%2C%0A++%7B%0A++++%22StatsHistoryTime%22%3A+%222019-02-06+12%3A30%3A00%22%2C%0A++++%22name%22%3A+%22debra%22%2C%0A++++%22hashrate%22%3A+1460613388%0A++%7D%2C%0A++%7B%0A++++%22StatsHistoryTime%22%3A+%222019-02-06+12%3A30%3A00%22%2C%0A++++%22name%22%3A+%22sally%22%2C%0A++++%22hashrate%22%3A+2147483647%0A++%7D%2C%0A++%7B%0A++++%22StatsHistoryTime%22%3A+%222019-02-06+12%3A30%3A00%22%2C%0A++++%22name%22%3A+%22bill%22%2C%0A++++%22hashrate%22%3A+2147483647%0A++%7D%0A%5D'
   44     1        INIT_FCALL                                                   'json_decode'
          2        SEND_VAR                                                     !0
          3        SEND_VAL                                                     <true>
          4        DO_ICALL                                             $7      
          5        ASSIGN                                                       !1, $7
   45     6        ASSIGN                                                       !2, <array>
   46     7      > FE_RESET_R                                           $10     !1, ->35
          8    > > FE_FETCH_R                                                   $10, !3, ->35
   47     9    >   FETCH_DIM_R                                          ~11     !3, 'StatsHistoryTime'
         10        ASSIGN                                                       !4, ~11
   48    11        INIT_FCALL                                                   'array_search'
         12        SEND_VAR                                                     !4
         13        INIT_FCALL                                                   'array_column'
         14        SEND_VAR                                                     !2
         15        SEND_VAL                                                     'period'
         16        DO_ICALL                                             $13     
         17        SEND_VAR                                                     $13
         18        DO_ICALL                                             $14     
         19        ASSIGN                                               ~15     !5, $14
         20        TYPE_CHECK                                      1018          ~15
         21      > JMPZ                                                         ~16, ->28
   49    22    >   FETCH_DIM_R                                          ~18     !3, 'name'
         23        FETCH_DIM_R                                          ~20     !3, 'hashrate'
         24        FETCH_DIM_W                                          $17     !2, !5
         25        ASSIGN_DIM                                                   $17, ~18
         26        OP_DATA                                                      ~20
   48    27      > JMP                                                          ->34
   52    28    >   INIT_ARRAY                                           ~22     !4, 'period'
         29        FETCH_DIM_R                                          ~23     !3, 'name'
         30        FETCH_DIM_R                                          ~24     !3, 'hashrate'
         31        ADD_ARRAY_ELEMENT                                    ~22     ~24, ~23
         32        ASSIGN_DIM                                                   !2
         33        OP_DATA                                                      ~22
   46    34    > > JMP                                                          ->8
         35    >   FE_FREE                                                      $10
   55    36        INIT_FCALL                                                   'json_encode'
         37        SEND_VAR                                                     !2
         38        DO_ICALL                                             $25     
         39        ECHO                                                         $25
         40      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
161.34 ms | 2151 KiB | 17 Q