3v4l.org

run code in 300+ PHP versions simultaneously
<?php $payload = '{ "params": { "nome": "jacopo", "cognome": "jacopo", "city.id": 1 } }'; $payload = json_decode($payload); if (is_object($payload->params)) { $v = $payload->params; foreach ($v as $key => $value) { if (strpos($key, '.') === false) { $newKey = '_x.' . $key; } else { $newKey = $key; } $v->{$newKey} = $value; unset($v->{$key}); } print_r($v); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 31
Branch analysis from position: 8
2 jumps found. (Code = 77) Position 1 = 11, Position 2 = 27
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 27
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 22
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
Branch analysis from position: 31
filename:       /in/HV53W
function name:  (null)
number of ops:  32
compiled vars:  !0 = $payload, !1 = $v, !2 = $value, !3 = $key, !4 = $newKey
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '%7B%0A++++%22params%22%3A+%7B%0A++++++++%22nome%22%3A+%22jacopo%22%2C%0A++++++++%22cognome%22%3A+%22jacopo%22%2C%0A++++++++%22city.id%22%3A+1%0A++++%7D%0A%7D'
    9     1        INIT_FCALL                                               'json_decode'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $6      
          4        ASSIGN                                                   !0, $6
   11     5        FETCH_OBJ_R                                      ~8      !0, 'params'
          6        TYPE_CHECK                                  256          ~8
          7      > JMPZ                                                     ~9, ->31
   12     8    >   FETCH_OBJ_R                                      ~10     !0, 'params'
          9        ASSIGN                                                   !1, ~10
   13    10      > FE_RESET_R                                       $12     !1, ->27
         11    > > FE_FETCH_R                                       ~13     $12, !2, ->27
         12    >   ASSIGN                                                   !3, ~13
   14    13        INIT_FCALL                                               'strpos'
         14        SEND_VAR                                                 !3
         15        SEND_VAL                                                 '.'
         16        DO_ICALL                                         $15     
         17        TYPE_CHECK                                    4          $15
         18      > JMPZ                                                     ~16, ->22
   15    19    >   CONCAT                                           ~17     '_x.', !3
         20        ASSIGN                                                   !4, ~17
         21      > JMP                                                      ->23
   17    22    >   ASSIGN                                                   !4, !3
   19    23    >   ASSIGN_OBJ                                               !1, !4
         24        OP_DATA                                                  !2
   20    25        UNSET_OBJ                                                !1, !3
   13    26      > JMP                                                      ->11
         27    >   FE_FREE                                                  $12
   23    28        INIT_FCALL                                               'print_r'
         29        SEND_VAR                                                 !1
         30        DO_ICALL                                                 
   24    31    > > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
170.62 ms | 1400 KiB | 19 Q