3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = [['A', 'B'],['C', 'B'],['B', 'C'],['A', 'A'],['B', 'A'],['B', 'B'],]; $temp = []; // temporary container $new_arr = array_filter($arr, function($e) use(&$temp) { $orig = $e; // create an original copy sort($e); // sort if(!in_array($e, $temp)) { $temp[] = $e; // push if doesn't exist yet return $orig; // return the orig } }); print_r($new_arr);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/C2emU
function name:  (null)
number of ops:  13
compiled vars:  !0 = $arr, !1 = $temp, !2 = $new_arr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        ASSIGN                                                   !1, <array>
    5     2        INIT_FCALL                                               'array_filter'
          3        SEND_VAR                                                 !0
          4        DECLARE_LAMBDA_FUNCTION                          ~5      [0]
          5        BIND_LEXICAL                                             ~5, !1
   12     6        SEND_VAL                                                 ~5
    5     7        DO_ICALL                                         $6      
          8        ASSIGN                                                   !2, $6
   13     9        INIT_FCALL                                               'print_r'
         10        SEND_VAR                                                 !2
         11        DO_ICALL                                                 
         12      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 15
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/C2emU
function name:  {closure}
number of ops:  16
compiled vars:  !0 = $e, !1 = $temp, !2 = $orig
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
    6     2        ASSIGN                                                   !2, !0
    7     3        INIT_FCALL                                               'sort'
          4        SEND_REF                                                 !0
          5        DO_ICALL                                                 
    8     6        INIT_FCALL                                               'in_array'
          7        SEND_VAR                                                 !0
          8        SEND_VAR                                                 !1
          9        DO_ICALL                                         $5      
         10        BOOL_NOT                                         ~6      $5
         11      > JMPZ                                                     ~6, ->15
    9    12    >   ASSIGN_DIM                                               !1
         13        OP_DATA                                                  !0
   10    14      > RETURN                                                   !2
   12    15    > > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
145.13 ms | 1009 KiB | 17 Q