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); $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}
number of ops:  26
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        INIT_FCALL                                               'max'
         10        FETCH_DIM_IS                                     ~5      !2, !1
         11        COALESCE                                         ~6      ~5
         12        QM_ASSIGN                                        ~6      0
         13        SEND_VAL                                                 ~6
         14        FETCH_DIM_IS                                     ~7      !3, !1
         15        COALESCE                                         ~8      ~7
         16        QM_ASSIGN                                        ~8      0
         17        SEND_VAL                                                 ~8
         18        DO_ICALL                                         $9      
         19        SEND_VAR                                                 $9
   18    20        SEND_VAR                                                 !1
   15    21        DO_ICALL                                         $10     
   18    22        SEND_UNPACK                                              $10
         23        CHECK_UNDEF_ARGS                                         
   13    24        DO_ICALL                                                 
   21    25      > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
224.06 ms | 1012 KiB | 19 Q