3v4l.org

run code in 300+ PHP versions simultaneously
<?php $customerProptype = (object)array ( 'first-name' => 'maria', 'last-name' => 'magdalena', 'phone-number' => 'no phone service', ); $customer = clone $customerProptype; foreach ($customer as $key => $value) { $key2 = str_replace('-', '_', $key); if ($key2 !== $key) { $customer->$key2 = $customer->$key; unset($customer->$key); } } var_export($customer, false); $customer = clone $customerProptype; foreach ($customer as $key => $value) { $key2 = str_replace('-', '_', $key); if ($key2 === $key) { continue; // nothing to do } $customer->$key2 = $customer->$key; unset($customer->$key); } var_export($customer, false); $customer = clone $customerProptype; foreach (clone $customer as $key => $value) { $key2 = str_replace('-', '_', $key); unset($customer->$key); $customer->$key2 = $value; } var_export($customer, false);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 20
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 20
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 19
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 19
Branch analysis from position: 20
2 jumps found. (Code = 77) Position 1 = 28, Position 2 = 44
Branch analysis from position: 28
2 jumps found. (Code = 78) Position 1 = 29, Position 2 = 44
Branch analysis from position: 29
2 jumps found. (Code = 43) Position 1 = 38, Position 2 = 39
Branch analysis from position: 38
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
Branch analysis from position: 39
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
Branch analysis from position: 44
2 jumps found. (Code = 77) Position 1 = 53, Position 2 = 65
Branch analysis from position: 53
2 jumps found. (Code = 78) Position 1 = 54, Position 2 = 65
Branch analysis from position: 54
1 jumps found. (Code = 42) Position 1 = 53
Branch analysis from position: 53
Branch analysis from position: 65
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 65
Branch analysis from position: 44
Branch analysis from position: 20
filename:       /in/vEXDj
function name:  (null)
number of ops:  71
compiled vars:  !0 = $customerProptype, !1 = $customer, !2 = $value, !3 = $key, !4 = $key2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   CAST                                          8  ~5      <array>
    3     1        ASSIGN                                                   !0, ~5
   10     2        CLONE                                            ~7      !0
          3        ASSIGN                                                   !1, ~7
   12     4      > FE_RESET_R                                       $9      !1, ->20
          5    > > FE_FETCH_R                                       ~10     $9, !2, ->20
          6    >   ASSIGN                                                   !3, ~10
   13     7        INIT_FCALL                                               'str_replace'
          8        SEND_VAL                                                 '-'
          9        SEND_VAL                                                 '_'
         10        SEND_VAR                                                 !3
         11        DO_ICALL                                         $12     
         12        ASSIGN                                                   !4, $12
   14    13        IS_NOT_IDENTICAL                                         !4, !3
         14      > JMPZ                                                     ~14, ->19
   15    15    >   FETCH_OBJ_R                                      ~16     !1, !3
         16        ASSIGN_OBJ                                               !1, !4
         17        OP_DATA                                                  ~16
   16    18        UNSET_OBJ                                                !1, !3
   12    19    > > JMP                                                      ->5
         20    >   FE_FREE                                                  $9
   20    21        INIT_FCALL                                               'var_export'
         22        SEND_VAR                                                 !1
         23        SEND_VAL                                                 <false>
         24        DO_ICALL                                                 
   23    25        CLONE                                            ~18     !0
         26        ASSIGN                                                   !1, ~18
   25    27      > FE_RESET_R                                       $20     !1, ->44
         28    > > FE_FETCH_R                                       ~21     $20, !2, ->44
         29    >   ASSIGN                                                   !3, ~21
   26    30        INIT_FCALL                                               'str_replace'
         31        SEND_VAL                                                 '-'
         32        SEND_VAL                                                 '_'
         33        SEND_VAR                                                 !3
         34        DO_ICALL                                         $23     
         35        ASSIGN                                                   !4, $23
   27    36        IS_IDENTICAL                                             !4, !3
         37      > JMPZ                                                     ~25, ->39
   28    38    > > JMP                                                      ->28
   30    39    >   FETCH_OBJ_R                                      ~27     !1, !3
         40        ASSIGN_OBJ                                               !1, !4
         41        OP_DATA                                                  ~27
   31    42        UNSET_OBJ                                                !1, !3
   25    43      > JMP                                                      ->28
         44    >   FE_FREE                                                  $20
   34    45        INIT_FCALL                                               'var_export'
         46        SEND_VAR                                                 !1
         47        SEND_VAL                                                 <false>
         48        DO_ICALL                                                 
   36    49        CLONE                                            ~29     !0
         50        ASSIGN                                                   !1, ~29
   38    51        CLONE                                            ~31     !1
         52      > FE_RESET_R                                       $32     ~31, ->65
         53    > > FE_FETCH_R                                       ~33     $32, !2, ->65
         54    >   ASSIGN                                                   !3, ~33
   39    55        INIT_FCALL                                               'str_replace'
         56        SEND_VAL                                                 '-'
         57        SEND_VAL                                                 '_'
         58        SEND_VAR                                                 !3
         59        DO_ICALL                                         $35     
         60        ASSIGN                                                   !4, $35
   40    61        UNSET_OBJ                                                !1, !3
   41    62        ASSIGN_OBJ                                               !1, !4
         63        OP_DATA                                                  !2
   38    64      > JMP                                                      ->53
         65    >   FE_FREE                                                  $32
   44    66        INIT_FCALL                                               'var_export'
         67        SEND_VAR                                                 !1
         68        SEND_VAL                                                 <false>
         69        DO_ICALL                                                 
         70      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.97 ms | 1008 KiB | 15 Q