3v4l.org

run code in 300+ PHP versions simultaneously
<?php $json = <<<JSON { "code": 200, "unit": null, "data": [ { "2022-11-16": 185.6159202 }, { "2022-11-17": 204.31997631 } ] } JSON; $result = []; foreach (json_decode($json, true)['data'] as $item) { $key = key($item); $result[] = ['date' => $key, 'value' => $item[$key]]; } var_export($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 19
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 19
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
filename:       /in/0HQ3D
function name:  (null)
number of ops:  24
compiled vars:  !0 = $json, !1 = $result, !2 = $item, !3 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%7B%0A++++%22code%22%3A+200%2C%0A++++%22unit%22%3A+null%2C%0A++++%22data%22%3A+%5B%0A++++++++%7B%0A++++++++++++%222022-11-16%22%3A+185.6159202%0A++++++++%7D%2C%0A++++++++%7B%0A++++++++++++%222022-11-17%22%3A+204.31997631%0A++++++++%7D%0A++++%5D%0A%7D'
   18     1        ASSIGN                                                   !1, <array>
   19     2        INIT_FCALL                                               'json_decode'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 <true>
          5        DO_ICALL                                         $6      
          6        FETCH_DIM_R                                      ~7      $6, 'data'
          7      > FE_RESET_R                                       $8      ~7, ->19
          8    > > FE_FETCH_R                                               $8, !2, ->19
   20     9    >   INIT_FCALL                                               'key'
         10        SEND_VAR                                                 !2
         11        DO_ICALL                                         $9      
         12        ASSIGN                                                   !3, $9
   21    13        INIT_ARRAY                                       ~12     !3, 'date'
         14        FETCH_DIM_R                                      ~13     !2, !3
         15        ADD_ARRAY_ELEMENT                                ~12     ~13, 'value'
         16        ASSIGN_DIM                                               !1
         17        OP_DATA                                                  ~12
   19    18      > JMP                                                      ->8
         19    >   FE_FREE                                                  $8
   23    20        INIT_FCALL                                               'var_export'
         21        SEND_VAR                                                 !1
         22        DO_ICALL                                                 
         23      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
137.6 ms | 1002 KiB | 16 Q