3v4l.org

run code in 300+ PHP versions simultaneously
<?php function reduce_array(array $source) { $picked_mark=array(); $result=array(); foreach($source as $key=>$subarray) { if(in_array(end($subarray),$picked_mark)) continue; $result[$key]=$subarray; $picked_mark[]=end($subarray); } return $result; } print_r(reduce_array(json_decode("[[0,1,2,3,4],[1,2,3,4],[2,3,4]]")));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Z2iZ5
function name:  (null)
number of ops:  10
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   INIT_FCALL                                               'print_r'
          1        INIT_FCALL                                               'reduce_array'
          2        INIT_FCALL                                               'json_decode'
          3        SEND_VAL                                                 '%5B%5B0%2C1%2C2%2C3%2C4%5D%2C%5B1%2C2%2C3%2C4%5D%2C%5B2%2C3%2C4%5D%5D'
          4        DO_ICALL                                         $0      
          5        SEND_VAR                                                 $0
          6        DO_FCALL                                      0  $1      
          7        SEND_VAR                                                 $1
          8        DO_ICALL                                                 
          9      > RETURN                                                   1

Function reduce_array:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 23
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 23
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 15
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
filename:       /in/Z2iZ5
function name:  reduce_array
number of ops:  26
compiled vars:  !0 = $source, !1 = $picked_mark, !2 = $result, !3 = $subarray, !4 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    4     1        ASSIGN                                                   !1, <array>
    5     2        ASSIGN                                                   !2, <array>
    6     3      > FE_RESET_R                                       $7      !0, ->23
          4    > > FE_FETCH_R                                       ~8      $7, !3, ->23
          5    >   ASSIGN                                                   !4, ~8
    8     6        INIT_FCALL                                               'in_array'
          7        INIT_FCALL                                               'end'
          8        SEND_REF                                                 !3
          9        DO_ICALL                                         $10     
         10        SEND_VAR                                                 $10
         11        SEND_VAR                                                 !1
         12        DO_ICALL                                         $11     
         13      > JMPZ                                                     $11, ->15
         14    > > JMP                                                      ->4
    9    15    >   ASSIGN_DIM                                               !2, !4
         16        OP_DATA                                                  !3
   10    17        INIT_FCALL                                               'end'
         18        SEND_REF                                                 !3
         19        DO_ICALL                                         $14     
         20        ASSIGN_DIM                                               !1
         21        OP_DATA                                                  $14
    6    22      > JMP                                                      ->4
         23    >   FE_FREE                                                  $7
   12    24      > RETURN                                                   !2
   13    25*     > RETURN                                                   null

End of function reduce_array

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
172.01 ms | 1403 KiB | 22 Q