3v4l.org

run code in 300+ PHP versions simultaneously
<?php $json = '{"description 1": { "year0": "49", "year1": "48", "year2": "876786", "year3": "1234" } }'; $a = json_decode($json, true); $r = []; foreach($a['description 1'] as $k => $v){ $index = (int) filter_var($k, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); $r[$k] = ($index == 0) ? '' : $a['description 1']['year'.--$index]; } print_r($r);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 30
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 30
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 22
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
filename:       /in/AtoZs
function name:  (null)
number of ops:  35
compiled vars:  !0 = $json, !1 = $a, !2 = $r, !3 = $v, !4 = $k, !5 = $index
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%7B%22description+1%22%3A+%7B%0A%09++%22year0%22%3A+%2249%22%2C%0A%09++%22year1%22%3A+%2248%22%2C%0A%09++%22year2%22%3A+%22876786%22%2C%0A%09++%22year3%22%3A+%221234%22%0A%09%7D%0A%7D'
   11     1        INIT_FCALL                                               'json_decode'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 <true>
          4        DO_ICALL                                         $7      
          5        ASSIGN                                                   !1, $7
   12     6        ASSIGN                                                   !2, <array>
   13     7        FETCH_DIM_R                                      ~10     !1, 'description+1'
          8      > FE_RESET_R                                       $11     ~10, ->30
          9    > > FE_FETCH_R                                       ~12     $11, !3, ->30
         10    >   ASSIGN                                                   !4, ~12
   14    11        INIT_FCALL                                               'filter_var'
         12        SEND_VAR                                                 !4
         13        SEND_VAL                                                 520
         14        SEND_VAL                                                 4096
         15        DO_ICALL                                         $14     
         16        CAST                                          4  ~15     $14
         17        ASSIGN                                                   !5, ~15
   15    18        IS_EQUAL                                                 !5, 0
         19      > JMPZ                                                     ~18, ->22
         20    >   QM_ASSIGN                                        ~19     ''
         21      > JMP                                                      ->27
         22    >   PRE_DEC                                          ~21     !5
         23        CONCAT                                           ~22     'year', ~21
         24        FETCH_DIM_R                                      ~20     !1, 'description+1'
         25        FETCH_DIM_R                                      ~23     ~20, ~22
         26        QM_ASSIGN                                        ~19     ~23
         27    >   ASSIGN_DIM                                               !2, !4
         28        OP_DATA                                                  ~19
   13    29      > JMP                                                      ->9
         30    >   FE_FREE                                                  $11
   17    31        INIT_FCALL                                               'print_r'
         32        SEND_VAR                                                 !2
         33        DO_ICALL                                                 
         34      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.01 ms | 1007 KiB | 16 Q