3v4l.org

run code in 500+ PHP versions simultaneously
<?php $arr = ['a' => 'abc']; $add = ['b' => 'bar', 'a' => 'foo']; echo json_encode(array_merge($arr, count($add) > 1 ? $add : [])); echo "\n---\n"; echo json_encode(array_replace($arr, count($add) > 1 ? $add : [])); echo "\n---\n"; echo json_encode($arr + (count($add) > 1 ? $add : [])); echo "\n---\n"; echo json_encode((count($add) > 1 ? $add : []) + $arr); echo "\n---\n"; echo json_encode([...$arr, ...count($add) > 1 ? $add : []]); echo "\n---\n"; echo json_encode([...count($add) > 1 ? $add : [], ...$arr]);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 10
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 25
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
2 jumps found. (Code = 43) Position 1 = 36, Position 2 = 38
Branch analysis from position: 36
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
2 jumps found. (Code = 43) Position 1 = 48, Position 2 = 50
Branch analysis from position: 48
1 jumps found. (Code = 42) Position 1 = 51
Branch analysis from position: 51
2 jumps found. (Code = 43) Position 1 = 62, Position 2 = 64
Branch analysis from position: 62
1 jumps found. (Code = 42) Position 1 = 65
Branch analysis from position: 65
2 jumps found. (Code = 43) Position 1 = 74, Position 2 = 76
Branch analysis from position: 74
1 jumps found. (Code = 42) Position 1 = 77
Branch analysis from position: 77
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 76
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 64
2 jumps found. (Code = 43) Position 1 = 74, Position 2 = 76
Branch analysis from position: 74
Branch analysis from position: 76
Branch analysis from position: 50
2 jumps found. (Code = 43) Position 1 = 62, Position 2 = 64
Branch analysis from position: 62
Branch analysis from position: 64
Branch analysis from position: 38
2 jumps found. (Code = 43) Position 1 = 48, Position 2 = 50
Branch analysis from position: 48
Branch analysis from position: 50
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 36, Position 2 = 38
Branch analysis from position: 36
Branch analysis from position: 38
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 25
Branch analysis from position: 23
Branch analysis from position: 25
filename:       /in/jhXEW
function name:  (null)
number of ops:  84
compiled vars:  !0 = $arr, !1 = $add
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
    5     1        ASSIGN                                                       !1, <array>
    7     2        INIT_FCALL                                                   'json_encode'
          3        INIT_FCALL                                                   'array_merge'
          4        SEND_VAR                                                     !0
          5        COUNT                                                ~4      !1
          6        IS_SMALLER                                                   1, ~4
          7      > JMPZ                                                         ~5, ->10
          8    >   QM_ASSIGN                                            ~6      !1
          9      > JMP                                                          ->11
         10    >   QM_ASSIGN                                            ~6      <array>
         11    >   SEND_VAL                                                     ~6
         12        DO_ICALL                                             $7      
         13        SEND_VAR                                                     $7
         14        DO_ICALL                                             $8      
         15        ECHO                                                         $8
    9    16        ECHO                                                         '%0A---%0A'
   11    17        INIT_FCALL                                                   'json_encode'
         18        INIT_FCALL                                                   'array_replace'
         19        SEND_VAR                                                     !0
         20        COUNT                                                ~9      !1
         21        IS_SMALLER                                                   1, ~9
         22      > JMPZ                                                         ~10, ->25
         23    >   QM_ASSIGN                                            ~11     !1
         24      > JMP                                                          ->26
         25    >   QM_ASSIGN                                            ~11     <array>
         26    >   SEND_VAL                                                     ~11
         27        DO_ICALL                                             $12     
         28        SEND_VAR                                                     $12
         29        DO_ICALL                                             $13     
         30        ECHO                                                         $13
   13    31        ECHO                                                         '%0A---%0A'
   15    32        INIT_FCALL                                                   'json_encode'
         33        COUNT                                                ~14     !1
         34        IS_SMALLER                                                   1, ~14
         35      > JMPZ                                                         ~15, ->38
         36    >   QM_ASSIGN                                            ~16     !1
         37      > JMP                                                          ->39
         38    >   QM_ASSIGN                                            ~16     <array>
         39    >   ADD                                                  ~17     !0, ~16
         40        SEND_VAL                                                     ~17
         41        DO_ICALL                                             $18     
         42        ECHO                                                         $18
   17    43        ECHO                                                         '%0A---%0A'
   19    44        INIT_FCALL                                                   'json_encode'
         45        COUNT                                                ~19     !1
         46        IS_SMALLER                                                   1, ~19
         47      > JMPZ                                                         ~20, ->50
         48    >   QM_ASSIGN                                            ~21     !1
         49      > JMP                                                          ->51
         50    >   QM_ASSIGN                                            ~21     <array>
         51    >   ADD                                                  ~22     ~21, !0
         52        SEND_VAL                                                     ~22
         53        DO_ICALL                                             $23     
         54        ECHO                                                         $23
   21    55        ECHO                                                         '%0A---%0A'
   23    56        INIT_FCALL                                                   'json_encode'
         57        INIT_ARRAY                                           ~24     
         58        ADD_ARRAY_UNPACK                                     ~24     !0
         59        COUNT                                                ~25     !1
         60        IS_SMALLER                                                   1, ~25
         61      > JMPZ                                                         ~26, ->64
         62    >   QM_ASSIGN                                            ~27     !1
         63      > JMP                                                          ->65
         64    >   QM_ASSIGN                                            ~27     <array>
         65    >   ADD_ARRAY_UNPACK                                     ~24     ~27
         66        SEND_VAL                                                     ~24
         67        DO_ICALL                                             $28     
         68        ECHO                                                         $28
   25    69        ECHO                                                         '%0A---%0A'
   27    70        INIT_FCALL                                                   'json_encode'
         71        COUNT                                                ~29     !1
         72        IS_SMALLER                                                   1, ~29
         73      > JMPZ                                                         ~30, ->76
         74    >   QM_ASSIGN                                            ~31     !1
         75      > JMP                                                          ->77
         76    >   QM_ASSIGN                                            ~31     <array>
         77    >   INIT_ARRAY                                           ~32     
         78        ADD_ARRAY_UNPACK                                     ~32     ~31
         79        ADD_ARRAY_UNPACK                                     ~32     !0
         80        SEND_VAL                                                     ~32
         81        DO_ICALL                                             $33     
         82        ECHO                                                         $33
         83      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
158.16 ms | 1762 KiB | 15 Q