3v4l.org

run code in 300+ PHP versions simultaneously
<?php $products = array( 33 => array( 31 => array( 'model' => 'Product 4', 'product_id' => 31, 'sku' => '', 'ean' => '1234', 'price' => '80.0000' ), 8733 => array( 'model' => 'qqq', 'product_id' => 8733, 'sku' => '', 'ean' => '1000', 'price' => '344.6281' ) ), 25 => array( 30 => array( 'model' => 'Product 3', 'product_id' => 30, 'sku' => '', 'ean' => '250', 'price' => '50.4132' ), 31 => array( 'model' => 'Product 4', 'product_id' => 31, 'sku' => '', 'ean' => '1234', 'price' => '80.0000' ) ) ); // Create a new array to store unique products $uniqueProducts = array(); foreach ($products as $parentKey => $items) { foreach ($items as $productId => $product) { $found = false; // Check if the product already exists in the uniqueProducts array foreach ($uniqueProducts as $existingItems) { if (isset($existingItems[$productId]) && $existingItems[$productId] == $product) { $found = true; break; } } // If the product is not found, add it to the uniqueProducts array if (!$found) { $uniqueProducts[$parentKey][$productId] = $product; } } } // Output the unique products array print_r($uniqueProducts);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 29
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 29
Branch analysis from position: 4
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 27
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 27
Branch analysis from position: 7
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 20
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 20
Branch analysis from position: 11
2 jumps found. (Code = 46) Position 1 = 13, Position 2 = 16
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 19
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 26
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 26
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 16
Branch analysis from position: 20
Branch analysis from position: 20
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 27
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
filename:       /in/dhsJj
function name:  (null)
number of ops:  34
compiled vars:  !0 = $products, !1 = $uniqueProducts, !2 = $items, !3 = $parentKey, !4 = $product, !5 = $productId, !6 = $found, !7 = $existingItems
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   39     1        ASSIGN                                                   !1, <array>
   41     2      > FE_RESET_R                                       $10     !0, ->29
          3    > > FE_FETCH_R                                       ~11     $10, !2, ->29
          4    >   ASSIGN                                                   !3, ~11
   42     5      > FE_RESET_R                                       $13     !2, ->27
          6    > > FE_FETCH_R                                       ~14     $13, !4, ->27
          7    >   ASSIGN                                                   !5, ~14
   43     8        ASSIGN                                                   !6, <false>
   45     9      > FE_RESET_R                                       $17     !1, ->20
         10    > > FE_FETCH_R                                               $17, !7, ->20
   46    11    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~18     !7, !5
         12      > JMPZ_EX                                          ~18     ~18, ->16
         13    >   FETCH_DIM_R                                      ~19     !7, !5
         14        IS_EQUAL                                         ~20     !4, ~19
         15        BOOL                                             ~18     ~20
         16    > > JMPZ                                                     ~18, ->19
   47    17    >   ASSIGN                                                   !6, <true>
   48    18      > JMP                                                      ->20
   45    19    > > JMP                                                      ->10
         20    >   FE_FREE                                                  $17
   52    21        BOOL_NOT                                         ~22     !6
         22      > JMPZ                                                     ~22, ->26
   53    23    >   FETCH_DIM_W                                      $23     !1, !3
         24        ASSIGN_DIM                                               $23, !5
         25        OP_DATA                                                  !4
   42    26    > > JMP                                                      ->6
         27    >   FE_FREE                                                  $13
   41    28      > JMP                                                      ->3
         29    >   FE_FREE                                                  $10
   59    30        INIT_FCALL                                               'print_r'
         31        SEND_VAR                                                 !1
         32        DO_ICALL                                                 
         33      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.34 ms | 1015 KiB | 14 Q