3v4l.org

run code in 300+ PHP versions simultaneously
<?php $json = <<<'JSON' { "abc": 157, "efg": 1, "hij": "1", "klm": "0.00", "created_at": { "date": "2020-04-08 12:53:34.682759", "timezone_type": 3, "timezone": "UTC" }, "updated_at": { "date": "2020-04-08 12:53:34.682759", "timezone_type": 3, "timezone": "UTC" } } JSON; $arr = json_decode($json, true); function delete_key(&$arr, $key) { foreach($arr as $k => &$v) { if ( $k === $key ) { unset($arr[$k]); continue; } if ( is_array($v) ) { delete_key($v, $key); } } } delete_key($arr, 'date'); print_r(json_encode($arr, JSON_PRETTY_PRINT));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ap86k
function name:  (null)
number of ops:  18
compiled vars:  !0 = $json, !1 = $arr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%7B%0A++%22abc%22%3A+157%2C%0A++%22efg%22%3A+1%2C%0A++%22hij%22%3A+%221%22%2C%0A++%22klm%22%3A+%220.00%22%2C%0A++%22created_at%22%3A+%7B%0A++++%22date%22%3A+%222020-04-08+12%3A53%3A34.682759%22%2C%0A++++%22timezone_type%22%3A+3%2C%0A++++%22timezone%22%3A+%22UTC%22%0A++%7D%2C%0A++%22updated_at%22%3A+%7B%0A++++%22date%22%3A+%222020-04-08+12%3A53%3A34.682759%22%2C%0A++++%22timezone_type%22%3A+3%2C%0A++++%22timezone%22%3A+%22UTC%22%0A++%7D%0A%7D'
   22     1        INIT_FCALL                                               'json_decode'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 <true>
          4        DO_ICALL                                         $3      
          5        ASSIGN                                                   !1, $3
   36     6        INIT_FCALL                                               'delete_key'
          7        SEND_REF                                                 !1
          8        SEND_VAL                                                 'date'
          9        DO_FCALL                                      0          
   38    10        INIT_FCALL                                               'print_r'
         11        INIT_FCALL                                               'json_encode'
         12        SEND_VAR                                                 !1
         13        SEND_VAL                                                 128
         14        DO_ICALL                                         $6      
         15        SEND_VAR                                                 $6
         16        DO_ICALL                                                 
         17      > RETURN                                                   1

Function delete_key:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 125) Position 1 = 3, Position 2 = 16
Branch analysis from position: 3
2 jumps found. (Code = 126) Position 1 = 4, Position 2 = 16
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 9
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 15
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 15
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
filename:       /in/ap86k
function name:  delete_key
number of ops:  18
compiled vars:  !0 = $arr, !1 = $key, !2 = $v, !3 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   25     2      > FE_RESET_RW                                      $4      !0, ->16
          3    > > FE_FETCH_RW                                      ~5      $4, !2, ->16
          4    >   ASSIGN                                                   !3, ~5
   26     5        IS_IDENTICAL                                             !3, !1
          6      > JMPZ                                                     ~7, ->9
   27     7    >   UNSET_DIM                                                !0, !3
   28     8      > JMP                                                      ->3
   30     9    >   TYPE_CHECK                                  128          !2
         10      > JMPZ                                                     ~8, ->15
   31    11    >   INIT_FCALL_BY_NAME                                       'delete_key'
         12        SEND_VAR_EX                                              !2
         13        SEND_VAR_EX                                              !1
         14        DO_FCALL                                      0          
   25    15    > > JMP                                                      ->3
         16    >   FE_FREE                                                  $4
   34    17      > RETURN                                                   null

End of function delete_key

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.11 ms | 965 KiB | 18 Q