3v4l.org

run code in 500+ 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) { $result[] = ['date' => key($item), 'value' => current($item)]; } var_export($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 20
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 20
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
filename:       /in/Mi16M
function name:  (null)
number of ops:  25
compiled vars:  !0 = $json, !1 = $result, !2 = $item
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                                             $5      
          6        FETCH_DIM_R                                          ~6      $5, 'data'
          7      > FE_RESET_R                                           $7      ~6, ->20
          8    > > FE_FETCH_R                                                   $7, !2, ->20
   20     9    >   INIT_FCALL                                                   'key'
         10        SEND_VAR                                                     !2
         11        DO_ICALL                                             $9      
         12        INIT_ARRAY                                           ~10     $9, 'date'
         13        INIT_FCALL                                                   'current'
         14        SEND_VAR                                                     !2
         15        DO_ICALL                                             $11     
         16        ADD_ARRAY_ELEMENT                                    ~10     $11, 'value'
         17        ASSIGN_DIM                                                   !1
         18        OP_DATA                                                      ~10
   19    19      > JMP                                                          ->8
         20    >   FE_FREE                                                      $7
   22    21        INIT_FCALL                                                   'var_export'
         22        SEND_VAR                                                     !1
         23        DO_ICALL                                                     
         24      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
167.06 ms | 1895 KiB | 16 Q