3v4l.org

run code in 300+ PHP versions simultaneously
<?php function subtract($a, $b) { $a2 = []; $lookup = array_count_values($b); foreach ($a as $v) { if ($lookup[$v] ?? 0) { $lookup[$v]--; } else { $a2[] = $v; } } return $a2; } var_dump(subtract( ['a', 'a', 'b', 'c', 'd', 'd', 'd', 'd'], ['a', 'b', 'd', 'd'] ));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/oWaRV
function name:  (null)
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'subtract'
   17     2        SEND_VAL                                                 <array>
   18     3        SEND_VAL                                                 <array>
          4        DO_FCALL                                      0  $0      
          5        SEND_VAR                                                 $0
          6        DO_ICALL                                                 
   19     7      > RETURN                                                   1

Function subtract:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 19
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 19
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 16
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
filename:       /in/oWaRV
function name:  subtract
number of ops:  22
compiled vars:  !0 = $a, !1 = $b, !2 = $a2, !3 = $lookup, !4 = $v
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2        ASSIGN                                                   !2, <array>
    5     3        INIT_FCALL                                               'array_count_values'
          4        SEND_VAR                                                 !1
          5        DO_ICALL                                         $6      
          6        ASSIGN                                                   !3, $6
    6     7      > FE_RESET_R                                       $8      !0, ->19
          8    > > FE_FETCH_R                                               $8, !4, ->19
    7     9    >   FETCH_DIM_IS                                     ~9      !3, !4
         10        COALESCE                                         ~10     ~9
         11        QM_ASSIGN                                        ~10     0
         12      > JMPZ                                                     ~10, ->16
    8    13    >   FETCH_DIM_RW                                     $11     !3, !4
         14        PRE_DEC                                                  $11
         15      > JMP                                                      ->18
   10    16    >   ASSIGN_DIM                                               !2
         17        OP_DATA                                                  !4
    6    18    > > JMP                                                      ->8
         19    >   FE_FREE                                                  $8
   13    20      > RETURN                                                   !2
   14    21*     > RETURN                                                   null

End of function subtract

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.8 ms | 1403 KiB | 18 Q