3v4l.org

run code in 500+ PHP versions simultaneously
<?php $array1 = [1, 4, 7, 3, 3, 3]; $array2 = [4, 0, 3, 4, 9, 9]; $counts1 = array_count_values($array1); foreach (array_count_values($array2) as $number => $count) { if ($count > ($counts1[$number] ?? 0)) { $counts1[$number] = $count; } } $result = []; foreach ($counts1 as $number => $count) { array_push($result, ...array_fill(0, $count, $number)); } var_export($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 20
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 20
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 19
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 19
Branch analysis from position: 20
2 jumps found. (Code = 77) Position 1 = 23, Position 2 = 36
Branch analysis from position: 23
2 jumps found. (Code = 78) Position 1 = 24, Position 2 = 36
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
Branch analysis from position: 36
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 36
Branch analysis from position: 20
filename:       /in/2cHqR
function name:  (null)
number of ops:  41
compiled vars:  !0 = $array1, !1 = $array2, !2 = $counts1, !3 = $count, !4 = $number, !5 = $result
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                                             $8      
          5        ASSIGN                                                       !2, $8
    7     6        INIT_FCALL                                                   'array_count_values'
          7        SEND_VAR                                                     !1
          8        DO_ICALL                                             $10     
          9      > FE_RESET_R                                           $11     $10, ->20
         10    > > FE_FETCH_R                                           ~12     $11, !3, ->20
         11    >   ASSIGN                                                       !4, ~12
    8    12        FETCH_DIM_IS                                         ~14     !2, !4
         13        COALESCE                                             ~15     ~14
         14        QM_ASSIGN                                            ~15     0
         15        IS_SMALLER                                                   ~15, !3
         16      > JMPZ                                                         ~16, ->19
    9    17    >   ASSIGN_DIM                                                   !2, !4
         18        OP_DATA                                                      !3
    7    19    > > JMP                                                          ->10
         20    >   FE_FREE                                                      $11
   12    21        ASSIGN                                                       !5, <array>
   13    22      > FE_RESET_R                                           $19     !2, ->36
         23    > > FE_FETCH_R                                           ~20     $19, !3, ->36
         24    >   ASSIGN                                                       !4, ~20
   14    25        INIT_FCALL                                                   'array_push'
         26        SEND_REF                                                     !5
         27        INIT_FCALL                                                   'array_fill'
         28        SEND_VAL                                                     0
         29        SEND_VAR                                                     !3
         30        SEND_VAR                                                     !4
         31        DO_ICALL                                             $22     
         32        SEND_UNPACK                                                  $22
         33        CHECK_UNDEF_ARGS                                             
         34        DO_ICALL                                                     
   13    35      > JMP                                                          ->23
         36    >   FE_FREE                                                      $19
   16    37        INIT_FCALL                                                   'var_export'
         38        SEND_VAR                                                     !5
         39        DO_ICALL                                                     
         40      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
148.25 ms | 1893 KiB | 16 Q