3v4l.org

run code in 500+ 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 = 33
Branch analysis from position: 13
2 jumps found. (Code = 78) Position 1 = 14, Position 2 = 33
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 33
filename:       /in/sjfGY
function name:  (null)
number of ops:  38
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, ->33
         13    > > FE_FETCH_R                                           ~16     $15, !5, ->33
         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        FETCH_DIM_IS                                         ~18     !2, !6
         20        COALESCE                                             ~19     ~18
         21        QM_ASSIGN                                            ~19     0
         22        FETCH_DIM_IS                                         ~20     !3, !6
         23        COALESCE                                             ~21     ~20
         24        QM_ASSIGN                                            ~21     0
         25        FRAMELESS_ICALL_2                max                 ~22     ~19, ~21
         26        SEND_VAL                                                     ~22
   15    27        SEND_VAR                                                     !6
   12    28        DO_ICALL                                             $23     
   15    29        SEND_UNPACK                                                  $23
         30        CHECK_UNDEF_ARGS                                             
   10    31        DO_ICALL                                                     
    9    32      > JMP                                                          ->13
         33    >   FE_FREE                                                      $15
   19    34        INIT_FCALL                                                   'var_export'
         35        SEND_VAR                                                     !4
         36        DO_ICALL                                                     
         37      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
162.22 ms | 1900 KiB | 18 Q