3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = array( array( 'name' => 'Supplier A', 'productName' => 'ABC', ), array( 'name' => 'Supplier B', 'productName' => 'ABC', ), array( 'name' => 'Supplier B', 'productName' => 'DEF', ), array( 'name' => 'Supplier C', 'productName' => 'XYZ', ), array( 'name' => 'Supplier D', 'productName' => 'BBB', ), array( 'name' => 'Supplier E', 'productName' => 'ABCDEF', ), array( 'name' => 'Supplier F', 'productName' => 'ABCDEF', ), ); $result = array_filter( $data, function($value) use ($data) { return count(array_filter( $data, function ($match) use ($value) { return $match == $value; } ) > 1); } ); var_dump($result);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/o4qmE
function name:  (null)
number of ops:  12
compiled vars:  !0 = $data, !1 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   34     1        INIT_FCALL                                               'array_filter'
   35     2        SEND_VAR                                                 !0
   36     3        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Fo4qmE%3A36%240'
          4        BIND_LEXICAL                                             ~3, !0
   43     5        SEND_VAL                                                 ~3
          6        DO_ICALL                                         $4      
   34     7        ASSIGN                                                   !1, $4
   45     8        INIT_FCALL                                               'var_dump'
          9        SEND_VAR                                                 !1
         10        DO_ICALL                                                 
         11      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2Fo4qmE%3A36%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/o4qmE
function name:  {closure}
number of ops:  12
compiled vars:  !0 = $value, !1 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   36     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   37     2        INIT_FCALL                                               'array_filter'
   38     3        SEND_VAR                                                 !1
   39     4        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Fo4qmE%3A39%241'
          5        BIND_LEXICAL                                             ~2, !0
   41     6        SEND_VAL                                                 ~2
          7        DO_ICALL                                         $3      
   42     8        IS_SMALLER                                       ~4      1, $3
          9        COUNT                                            ~5      ~4
         10      > RETURN                                                   ~5
   43    11*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Fo4qmE%3A36%240

Function %00%7Bclosure%7D%2Fin%2Fo4qmE%3A39%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/o4qmE
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $match, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   39     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   40     2        IS_EQUAL                                         ~2      !0, !1
          3      > RETURN                                                   ~2
   41     4*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Fo4qmE%3A39%241

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.79 ms | 1396 KiB | 17 Q