3v4l.org

run code in 300+ PHP versions simultaneously
<?php $json = '[{ "11111111": { "id": "val_somevalue5555", "customer": { "32312": { "name": "jane doe" } } }, "2222222": { "id": "val_somevalue25", "customer": { "32312234": { "name": "jane doe" } } } }]'; $jsonarr = json_decode($json, true); $newarr = []; foreach($jsonarr as $value) { $key = key($value); $newarr[] = ['key' => $key, 'id' => $value[$key]['id']]; } var_dump($newarr);
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/HdMtA
function name:  (null)
number of ops:  25
compiled vars:  !0 = $json, !1 = $jsonarr, !2 = $newarr, !3 = $value, !4 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%5B%7B%0A++++%2211111111%22%3A+%7B%0A++++++++%22id%22%3A+%22val_somevalue5555%22%2C%0A++++++++%22customer%22%3A+%7B%0A++++++++++++%2232312%22%3A+%7B%0A++++++++++++++++%22name%22%3A+%22jane+doe%22%0A++++++++++++%7D%0A++++++++%7D%0A++++%7D%2C%0A++++%222222222%22%3A+%7B%0A++++++++%22id%22%3A+%22val_somevalue25%22%2C%0A++++++++%22customer%22%3A+%7B%0A++++++++++++%2232312234%22%3A+%7B%0A++++++++++++++++%22name%22%3A+%22jane+doe%22%0A++++++++++++%7D%0A++++++++%7D%0A++++%7D%0A%7D%5D'
   22     1        INIT_FCALL                                               'json_decode'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 <true>
          4        DO_ICALL                                         $6      
          5        ASSIGN                                                   !1, $6
   24     6        ASSIGN                                                   !2, <array>
   26     7      > FE_RESET_R                                       $9      !1, ->20
          8    > > FE_FETCH_R                                               $9, !3, ->20
   28     9    >   INIT_FCALL                                               'key'
         10        SEND_VAR                                                 !3
         11        DO_ICALL                                         $10     
         12        ASSIGN                                                   !4, $10
   29    13        INIT_ARRAY                                       ~13     !4, 'key'
         14        FETCH_DIM_R                                      ~14     !3, !4
         15        FETCH_DIM_R                                      ~15     ~14, 'id'
         16        ADD_ARRAY_ELEMENT                                ~13     ~15, 'id'
         17        ASSIGN_DIM                                               !2
         18        OP_DATA                                                  ~13
   26    19      > JMP                                                      ->8
         20    >   FE_FREE                                                  $9
   31    21        INIT_FCALL                                               'var_dump'
         22        SEND_VAR                                                 !2
         23        DO_ICALL                                                 
         24      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
140.53 ms | 1003 KiB | 16 Q