3v4l.org

run code in 300+ PHP versions simultaneously
<?php function append(array $init, array $add, $key = null) { $_init = $init; if (is_null($key)) { $_init[] = $add; return array_merge($_init, $init); } else { $_init[$key] = $add; return [ $key => array_merge($_init[$key], $init[$key]) ]; } } $a = [ 'phone' => [ 'code' => '+38', ], ]; $b = [ 'prefix' => '095', 'number' => '7700418', ]; var_dump(append($a, $b, 'phone')); $a = [ 'code' => '+38', ]; $b = [ 'prefix' => '095', 'number' => '7700418', ]; var_dump(append($a, $b));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EIvvb
function name:  (null)
number of ops:  20
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   ASSIGN                                                   !0, <array>
   21     1        ASSIGN                                                   !1, <array>
   25     2        INIT_FCALL                                               'var_dump'
          3        INIT_FCALL                                               'append'
          4        SEND_VAR                                                 !0
          5        SEND_VAR                                                 !1
          6        SEND_VAL                                                 'phone'
          7        DO_FCALL                                      0  $4      
          8        SEND_VAR                                                 $4
          9        DO_ICALL                                                 
   28    10        ASSIGN                                                   !0, <array>
   31    11        ASSIGN                                                   !1, <array>
   35    12        INIT_FCALL                                               'var_dump'
         13        INIT_FCALL                                               'append'
         14        SEND_VAR                                                 !0
         15        SEND_VAR                                                 !1
         16        DO_FCALL                                      0  $8      
         17        SEND_VAR                                                 $8
         18        DO_ICALL                                                 
         19      > RETURN                                                   1

Function append:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 14
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EIvvb
function name:  append
number of ops:  25
compiled vars:  !0 = $init, !1 = $add, !2 = $key, !3 = $_init
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      null
    4     3        ASSIGN                                                   !3, !0
    5     4        TYPE_CHECK                                    2          !2
          5      > JMPZ                                                     ~5, ->14
    6     6    >   ASSIGN_DIM                                               !3
          7        OP_DATA                                                  !1
    7     8        INIT_FCALL                                               'array_merge'
          9        SEND_VAR                                                 !3
         10        SEND_VAR                                                 !0
         11        DO_ICALL                                         $7      
         12      > RETURN                                                   $7
         13*       JMP                                                      ->24
    9    14    >   ASSIGN_DIM                                               !3, !2
         15        OP_DATA                                                  !1
   11    16        INIT_FCALL                                               'array_merge'
         17        FETCH_DIM_R                                      ~9      !3, !2
         18        SEND_VAL                                                 ~9
         19        FETCH_DIM_R                                      ~10     !0, !2
         20        SEND_VAL                                                 ~10
         21        DO_ICALL                                         $11     
         22        INIT_ARRAY                                       ~12     $11, !2
         23      > RETURN                                                   ~12
   14    24*     > RETURN                                                   null

End of function append

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
167.99 ms | 1403 KiB | 19 Q