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); $allCounts = $counts1 + $counts2; $result = []; array_walk( $allCounts, function($v, $k) use(&$counts1, &$counts2, &$result) { array_push( $result, ...array_fill( 0, max($counts1[$k] ?? 0, $counts2[$k] ?? 0), $k ) ); } ); var_export($result);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9W1UC
function name:  (null)
number of ops:  25
compiled vars:  !0 = $array1, !1 = $array2, !2 = $counts1, !3 = $counts2, !4 = $allCounts, !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        ASSIGN                                                       !3, $10
    8    10        ADD                                                  ~12     !2, !3
         11        ASSIGN                                                       !4, ~12
    9    12        ASSIGN                                                       !5, <array>
   10    13        INIT_FCALL                                                   'array_walk'
   11    14        SEND_REF                                                     !4
   12    15        DECLARE_LAMBDA_FUNCTION                              ~15     [0]
         16        BIND_LEXICAL                                                 ~15, !2
         17        BIND_LEXICAL                                                 ~15, !3
         18        BIND_LEXICAL                                                 ~15, !5
   21    19        SEND_VAL                                                     ~15
   10    20        DO_ICALL                                                     
   23    21        INIT_FCALL                                                   'var_export'
         22        SEND_VAR                                                     !5
         23        DO_ICALL                                                     
         24      > RETURN                                                       1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9W1UC
function name:  {closure:/in/9W1UC:12}
number of ops:  23
compiled vars:  !0 = $v, !1 = $k, !2 = $counts1, !3 = $counts2, !4 = $result
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   12     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
          2        BIND_STATIC                                                  !2
          3        BIND_STATIC                                                  !3
          4        BIND_STATIC                                                  !4
   13     5        INIT_FCALL                                                   'array_push'
   14     6        SEND_REF                                                     !4
   15     7        INIT_FCALL                                                   'array_fill'
   16     8        SEND_VAL                                                     0
   17     9        FETCH_DIM_IS                                         ~5      !2, !1
         10        COALESCE                                             ~6      ~5
         11        QM_ASSIGN                                            ~6      0
         12        FETCH_DIM_IS                                         ~7      !3, !1
         13        COALESCE                                             ~8      ~7
         14        QM_ASSIGN                                            ~8      0
         15        FRAMELESS_ICALL_2                max                 ~9      ~6, ~8
         16        SEND_VAL                                                     ~9
   18    17        SEND_VAR                                                     !1
   15    18        DO_ICALL                                             $10     
   18    19        SEND_UNPACK                                                  $10
         20        CHECK_UNDEF_ARGS                                             
   13    21        DO_ICALL                                                     
   21    22      > RETURN                                                       null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
193.42 ms | 1889 KiB | 18 Q