3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array1 = [1, 3, 3, 3, 4, 7, 7, 8, 8]; $array2 = [0, 3, 3, 4, 4, 9, 9, 9]; $counts1 = array_count_values($array1); $counts2 = array_count_values($array2); $result = []; foreach ($counts1 + $counts2 as $num => $cnt) { array_push( $result, ...array_fill( 0, max($counts1[$num] ?? 0, $counts2[$num] ?? 0), $num ) ); } var_export($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 13, Position 2 = 36
Branch analysis from position: 13
2 jumps found. (Code = 78) Position 1 = 14, Position 2 = 36
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 36
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 36
filename:       /in/sjfGY
function name:  (null)
number of ops:  41
compiled vars:  !0 = $array1, !1 = $array2, !2 = $counts1, !3 = $counts2, !4 = $result, !5 = $cnt, !6 = $num
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        ASSIGN                                                   !1, <array>
    6     2        INIT_FCALL                                               'array_count_values'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $9      
          5        ASSIGN                                                   !2, $9
    7     6        INIT_FCALL                                               'array_count_values'
          7        SEND_VAR                                                 !1
          8        DO_ICALL                                         $11     
          9        ASSIGN                                                   !3, $11
    8    10        ASSIGN                                                   !4, <array>
    9    11        ADD                                              ~14     !2, !3
         12      > FE_RESET_R                                       $15     ~14, ->36
         13    > > FE_FETCH_R                                       ~16     $15, !5, ->36
         14    >   ASSIGN                                                   !6, ~16
   10    15        INIT_FCALL                                               'array_push'
   11    16        SEND_REF                                                 !4
   12    17        INIT_FCALL                                               'array_fill'
   13    18        SEND_VAL                                                 0
   14    19        INIT_FCALL                                               'max'
         20        FETCH_DIM_IS                                     ~18     !2, !6
         21        COALESCE                                         ~19     ~18
         22        QM_ASSIGN                                        ~19     0
         23        SEND_VAL                                                 ~19
         24        FETCH_DIM_IS                                     ~20     !3, !6
         25        COALESCE                                         ~21     ~20
         26        QM_ASSIGN                                        ~21     0
         27        SEND_VAL                                                 ~21
         28        DO_ICALL                                         $22     
         29        SEND_VAR                                                 $22
   15    30        SEND_VAR                                                 !6
   12    31        DO_ICALL                                         $23     
   15    32        SEND_UNPACK                                              $23
         33        CHECK_UNDEF_ARGS                                         
   10    34        DO_ICALL                                                 
    9    35      > JMP                                                      ->13
         36    >   FE_FREE                                                  $15
   19    37        INIT_FCALL                                               'var_export'
         38        SEND_VAR                                                 !4
         39        DO_ICALL                                                 
         40      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.44 ms | 1011 KiB | 18 Q