3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array1 = [ Array ( 'nombre_entrada' => 'Entrada General', 'precio_productor' => 250, 'id_funcion' => 907, ), Array ( 'nombre_entrada' => 'Entrada General', 'precio_productor' => 300, 'id_funcion' => 907, ), Array ( 'nombre_entrada' => 'Entrada General', 'precio_productor' => 350, 'id_funcion' => 907, ), Array ( 'nombre_entrada' => '2 entradas x', 'precio_productor' => 400, 'id_funcion' => 907, ) ]; $array2 = [ Array ( 'nombre_entrada' => 'Entrada General', 'precio_productor' => 350, 'id_funcion' => 907, ), Array ( 'nombre_entrada' => '2 entradas x', 'precio_productor' => 400, 'id_funcion' => 907, ), ]; $newArray = []; foreach ($array2 as $item) { $newArray[serialize($item)] = $item; } // next - filter your first array: $filteredArray = array_filter( $array1, function($v) use ($newArray) { // here serialize `$v` and check if key // same as serialized `$v` exists in $newArray return !isset($newArray[serialize($v)]); } ); print_r($filteredArray);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 11
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 11
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
filename:       /in/aKba9
function name:  (null)
number of ops:  23
compiled vars:  !0 = $array1, !1 = $array2, !2 = $newArray, !3 = $item, !4 = $filteredArray
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   29     1        ASSIGN                                                   !1, <array>
   44     2        ASSIGN                                                   !2, <array>
   45     3      > FE_RESET_R                                       $8      !1, ->11
          4    > > FE_FETCH_R                                               $8, !3, ->11
   46     5    >   INIT_FCALL                                               'serialize'
          6        SEND_VAR                                                 !3
          7        DO_ICALL                                         $9      
          8        ASSIGN_DIM                                               !2, $9
          9        OP_DATA                                                  !3
   45    10      > JMP                                                      ->4
         11    >   FE_FREE                                                  $8
   50    12        INIT_FCALL                                               'array_filter'
   51    13        SEND_VAR                                                 !0
   52    14        DECLARE_LAMBDA_FUNCTION                          ~11     [0]
         15        BIND_LEXICAL                                             ~11, !2
   56    16        SEND_VAL                                                 ~11
   50    17        DO_ICALL                                         $12     
         18        ASSIGN                                                   !4, $12
   58    19        INIT_FCALL                                               'print_r'
         20        SEND_VAR                                                 !4
         21        DO_ICALL                                                 
         22      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/aKba9
function name:  {closure}
number of ops:  9
compiled vars:  !0 = $v, !1 = $newArray
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   52     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   55     2        INIT_FCALL                                               'serialize'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $2      
          5        ISSET_ISEMPTY_DIM_OBJ                         0  ~3      !1, $2
          6        BOOL_NOT                                         ~4      ~3
          7      > RETURN                                                   ~4
   56     8*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
272.52 ms | 1008 KiB | 16 Q