3v4l.org

run code in 300+ PHP versions simultaneously
<?php $subject = array( array("Yolo" => "Swag", 2, 3), array("Thwag" => "Molo", 2, 4), array("Yolo" => "Thwag", 2, 3) ); $unique = array_reduce($subject, function($final, $article){ static $seen = array(); if ( ! array_key_exists($article[2], $seen)) { $seen[$article[2]] = NULL; $final[] = $article; } return $final; }); print_r($subject); print_r($unique);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/78qjW
function name:  (null)
number of ops:  14
compiled vars:  !0 = $subject, !1 = $unique
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    8     1        INIT_FCALL                                               'array_reduce'
          2        SEND_VAR                                                 !0
          3        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F78qjW%3A8%240'
   15     4        SEND_VAL                                                 ~3
          5        DO_ICALL                                         $4      
    8     6        ASSIGN                                                   !1, $4
   17     7        INIT_FCALL                                               'print_r'
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                                 
   18    10        INIT_FCALL                                               'print_r'
         11        SEND_VAR                                                 !1
         12        DO_ICALL                                                 
         13      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2F78qjW%3A8%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 12
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
filename:       /in/78qjW
function name:  {closure}
number of ops:  14
compiled vars:  !0 = $final, !1 = $article, !2 = $seen
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    9     2        BIND_STATIC                                              !2
   10     3        FETCH_DIM_R                                      ~3      !1, 2
          4        ARRAY_KEY_EXISTS                                 ~4      ~3, !2
          5        BOOL_NOT                                         ~5      ~4
          6      > JMPZ                                                     ~5, ->12
   11     7    >   FETCH_DIM_R                                      ~6      !1, 2
          8        ASSIGN_DIM                                               !2, ~6
          9        OP_DATA                                                  null
   12    10        ASSIGN_DIM                                               !0
         11        OP_DATA                                                  !1
   14    12    > > RETURN                                                   !0
   15    13*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F78qjW%3A8%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.16 ms | 1396 KiB | 17 Q