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); $keepFrom1 = array_keys( array_filter( $counts1, fn($count, $number) => ($counts2[$number] ?? 0) <= $count, ARRAY_FILTER_USE_BOTH ) ); var_export( array_merge( array_intersect($array1, $keepFrom1), array_diff($array2, $keepFrom1) ) );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/P9sgv
function name:  (null)
number of ops:  37
compiled vars:  !0 = $array1, !1 = $array2, !2 = $counts1, !3 = $counts2, !4 = $keepFrom1
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                                         $7      
          5        ASSIGN                                                   !2, $7
    7     6        INIT_FCALL                                               'array_count_values'
          7        SEND_VAR                                                 !1
          8        DO_ICALL                                         $9      
          9        ASSIGN                                                   !3, $9
    8    10        INIT_FCALL                                               'array_keys'
    9    11        INIT_FCALL                                               'array_filter'
   10    12        SEND_VAR                                                 !2
   11    13        DECLARE_LAMBDA_FUNCTION                          ~11     [0]
         14        BIND_LEXICAL                                             ~11, !3
         15        SEND_VAL                                                 ~11
   12    16        SEND_VAL                                                 1
    9    17        DO_ICALL                                         $12     
   12    18        SEND_VAR                                                 $12
    8    19        DO_ICALL                                         $13     
         20        ASSIGN                                                   !4, $13
   16    21        INIT_FCALL                                               'var_export'
   17    22        INIT_FCALL                                               'array_merge'
   18    23        INIT_FCALL                                               'array_intersect'
         24        SEND_VAR                                                 !0
         25        SEND_VAR                                                 !4
         26        DO_ICALL                                         $15     
         27        SEND_VAR                                                 $15
   19    28        INIT_FCALL                                               'array_diff'
         29        SEND_VAR                                                 !1
         30        SEND_VAR                                                 !4
         31        DO_ICALL                                         $16     
         32        SEND_VAR                                                 $16
   17    33        DO_ICALL                                         $17     
   19    34        SEND_VAR                                                 $17
   16    35        DO_ICALL                                                 
   21    36      > 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/P9sgv
function name:  {closure}
number of ops:  9
compiled vars:  !0 = $count, !1 = $number, !2 = $counts2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
          3        FETCH_DIM_IS                                     ~3      !2, !1
          4        COALESCE                                         ~4      ~3
          5        QM_ASSIGN                                        ~4      0
          6        IS_SMALLER_OR_EQUAL                              ~5      ~4, !0
          7      > RETURN                                                   ~5
          8*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.06 ms | 1013 KiB | 20 Q