3v4l.org

run code in 300+ PHP versions simultaneously
<?php $fromBackend = [ 114466 => [ "BrandID" => 136, "record" => 114466 ], 114467 => [ "BrandID" => 1, "record" => 114467 ], 114468 => [ "BrandID" => 2, "record" => 114468 ] ]; $fromFrontEnd = array(); // (object)['id' => 117, 'brandId' => 1], (object)['id' => 118, 'brandId' => 2]); $recordsToDelete = array(); foreach ($fromBackend as $backendItem) { $found = false; foreach ($fromFrontEnd as $frontendItem) { if ($frontendItem->brandId == $backendItem['BrandID']) { $found = true; break; } } if (!$found) $recordsToDelete[] = $backendItem['record']; } print_r($recordsToDelete); $recordsToDelete = array(); foreach ($fromBackend as $backendItem) { foreach ($fromFrontEnd as $frontendItem) { if ($frontendItem->brandId == $backendItem['BrandID']) break; } if (($frontendItem->brandId ?? -1) != $backendItem['BrandID']) $recordsToDelete[] = $backendItem['record']; } print_r($recordsToDelete);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 22
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 22
Branch analysis from position: 5
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 15
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 15
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 14
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 21
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 21
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 15
Branch analysis from position: 15
Branch analysis from position: 22
2 jumps found. (Code = 77) Position 1 = 28, Position 2 = 48
Branch analysis from position: 28
2 jumps found. (Code = 78) Position 1 = 29, Position 2 = 48
Branch analysis from position: 29
2 jumps found. (Code = 77) Position 1 = 30, Position 2 = 37
Branch analysis from position: 30
2 jumps found. (Code = 78) Position 1 = 31, Position 2 = 37
Branch analysis from position: 31
2 jumps found. (Code = 43) Position 1 = 35, Position 2 = 36
Branch analysis from position: 35
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
2 jumps found. (Code = 43) Position 1 = 44, Position 2 = 47
Branch analysis from position: 44
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
Branch analysis from position: 47
Branch analysis from position: 36
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
Branch analysis from position: 37
Branch analysis from position: 37
Branch analysis from position: 48
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 48
Branch analysis from position: 22
filename:       /in/vqlLt
function name:  (null)
number of ops:  53
compiled vars:  !0 = $fromBackend, !1 = $fromFrontEnd, !2 = $recordsToDelete, !3 = $backendItem, !4 = $found, !5 = $frontendItem
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   17     1        ASSIGN                                                   !1, <array>
   19     2        ASSIGN                                                   !2, <array>
   20     3      > FE_RESET_R                                       $9      !0, ->22
          4    > > FE_FETCH_R                                               $9, !3, ->22
   21     5    >   ASSIGN                                                   !4, <false>
   22     6      > FE_RESET_R                                       $11     !1, ->15
          7    > > FE_FETCH_R                                               $11, !5, ->15
   23     8    >   FETCH_OBJ_R                                      ~12     !5, 'brandId'
          9        FETCH_DIM_R                                      ~13     !3, 'BrandID'
         10        IS_EQUAL                                                 ~12, ~13
         11      > JMPZ                                                     ~14, ->14
   24    12    >   ASSIGN                                                   !4, <true>
   25    13      > JMP                                                      ->15
   22    14    > > JMP                                                      ->7
         15    >   FE_FREE                                                  $11
   28    16        BOOL_NOT                                         ~16     !4
         17      > JMPZ                                                     ~16, ->21
         18    >   FETCH_DIM_R                                      ~18     !3, 'record'
         19        ASSIGN_DIM                                               !2
         20        OP_DATA                                                  ~18
   20    21    > > JMP                                                      ->4
         22    >   FE_FREE                                                  $9
   30    23        INIT_FCALL                                               'print_r'
         24        SEND_VAR                                                 !2
         25        DO_ICALL                                                 
   32    26        ASSIGN                                                   !2, <array>
   33    27      > FE_RESET_R                                       $21     !0, ->48
         28    > > FE_FETCH_R                                               $21, !3, ->48
   34    29    > > FE_RESET_R                                       $22     !1, ->37
         30    > > FE_FETCH_R                                               $22, !5, ->37
   35    31    >   FETCH_OBJ_R                                      ~23     !5, 'brandId'
         32        FETCH_DIM_R                                      ~24     !3, 'BrandID'
         33        IS_EQUAL                                                 ~23, ~24
         34      > JMPZ                                                     ~25, ->36
         35    > > JMP                                                      ->37
   34    36    > > JMP                                                      ->30
         37    >   FE_FREE                                                  $22
   37    38        FETCH_OBJ_IS                                     ~26     !5, 'brandId'
         39        COALESCE                                         ~27     ~26
         40        QM_ASSIGN                                        ~27     -1
         41        FETCH_DIM_R                                      ~28     !3, 'BrandID'
         42        IS_NOT_EQUAL                                             ~27, ~28
         43      > JMPZ                                                     ~29, ->47
         44    >   FETCH_DIM_R                                      ~31     !3, 'record'
         45        ASSIGN_DIM                                               !2
         46        OP_DATA                                                  ~31
   33    47    > > JMP                                                      ->28
         48    >   FE_FREE                                                  $21
   39    49        INIT_FCALL                                               'print_r'
         50        SEND_VAR                                                 !2
         51        DO_ICALL                                                 
         52      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
163.78 ms | 1400 KiB | 15 Q