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) { echo 'TEST', PHP_EOL; return count(array_filter( $data, function ($match) use ($value) { echo $match['productName'], ' => ', $value['productName'], PHP_EOL; return $match['productName'] === $value['productName']; } ) > 1); } ); var_dump($result);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7O30Y
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%2F7O30Y%3A36%240'
          4        BIND_LEXICAL                                             ~3, !0
   45     5        SEND_VAL                                                 ~3
          6        DO_ICALL                                         $4      
   34     7        ASSIGN                                                   !1, $4
   47     8        INIT_FCALL                                               'var_dump'
          9        SEND_VAR                                                 !1
         10        DO_ICALL                                                 
         11      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2F7O30Y%3A36%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7O30Y
function name:  {closure}
number of ops:  14
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        ECHO                                                     'TEST'
          3        ECHO                                                     '%0A'
   38     4        INIT_FCALL                                               'array_filter'
   39     5        SEND_VAR                                                 !1
   40     6        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F7O30Y%3A40%241'
          7        BIND_LEXICAL                                             ~2, !0
   43     8        SEND_VAL                                                 ~2
          9        DO_ICALL                                         $3      
   44    10        IS_SMALLER                                       ~4      1, $3
         11        COUNT                                            ~5      ~4
         12      > RETURN                                                   ~5
   45    13*     > RETURN                                                   null

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

Function %00%7Bclosure%7D%2Fin%2F7O30Y%3A40%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7O30Y
function name:  {closure}
number of ops:  13
compiled vars:  !0 = $match, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   40     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   41     2        FETCH_DIM_R                                      ~2      !0, 'productName'
          3        ECHO                                                     ~2
          4        ECHO                                                     '+%3D%3E+'
          5        FETCH_DIM_R                                      ~3      !1, 'productName'
          6        ECHO                                                     ~3
          7        ECHO                                                     '%0A'
   42     8        FETCH_DIM_R                                      ~4      !0, 'productName'
          9        FETCH_DIM_R                                      ~5      !1, 'productName'
         10        IS_IDENTICAL                                     ~6      ~4, ~5
         11      > RETURN                                                   ~6
   43    12*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F7O30Y%3A40%241

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.01 ms | 1400 KiB | 17 Q