3v4l.org

run code in 300+ PHP versions simultaneously
<?php function doopScooper($dataArray, $uniqueKeys){ foreach($dataArray as $row){ $checkArray = array(); foreach($uniqueKeys as $key) $checkArray[$key] = isset($row[$key]) ? $row[$key] : NULL; $checkArrayString = json_encode($checkArray); $matchcount = 0; foreach($dataArray as $id=>$array){ $currentArray = []; foreach($uniqueKeys as $key) $currentArray[$key] = isset($array[$key]) ? $array[$key] : NULL; $currentArrayString = json_encode($currentArray); if($currentArrayString == $checkArrayString) $matchcount++; if($matchcount > 1) unset($dataArray[$id]); } } return $dataArray; } $dataArray = array( array("id"=>0, "fname"=>"Robert", "lname"=>"Pamblam", "address"=>"1231 main st"), array("id"=>1, "fname"=>"Robert", "lname"=>"Pamblam", "address"=>"1232 main st"), array("id"=>2, "fname"=>"Roberto", "lname"=>"Pamblam", "address"=>"1233 main st"), array("id"=>3, "fname"=>"Roberta", "lname"=>"Pamblam", "address"=>"1234 main st"), array("id"=>4, "fname"=>"Roberta", "lname"=>"Pamblam", "address"=>"1235 main st"), array("id"=>5, "fname"=>"Robert", "lname"=>"Pamblamo", "address"=>"1236 main st"), array("id"=>6, "fname"=>"Robert", "lname"=>"Pamblamo", "address"=>"1237 main st") ); $uniqueKeys = array('fname', 'lname'); $newarray = doopScooper($dataArray, $uniqueKeys); var_dump($newarray); exit;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 79) Position 1 = -2
filename:       /in/oYVkF
function name:  (null)
number of ops:  12
compiled vars:  !0 = $dataArray, !1 = $uniqueKeys, !2 = $newarray
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   ASSIGN                                                   !0, <array>
   32     1        ASSIGN                                                   !1, <array>
   33     2        INIT_FCALL                                               'doopscooper'
          3        SEND_VAR                                                 !0
          4        SEND_VAR                                                 !1
          5        DO_FCALL                                      0  $5      
          6        ASSIGN                                                   !2, $5
   35     7        INIT_FCALL                                               'var_dump'
          8        SEND_VAR                                                 !2
          9        DO_ICALL                                                 
         10      > EXIT                                                     
         11*     > RETURN                                                   1

Function doopscooper:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 51
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 51
Branch analysis from position: 4
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 16
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 16
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 12
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 16
2 jumps found. (Code = 77) Position 1 = 23, Position 2 = 49
Branch analysis from position: 23
2 jumps found. (Code = 78) Position 1 = 24, Position 2 = 49
Branch analysis from position: 24
2 jumps found. (Code = 77) Position 1 = 27, Position 2 = 37
Branch analysis from position: 27
2 jumps found. (Code = 78) Position 1 = 28, Position 2 = 37
Branch analysis from position: 28
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 33
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 34
Branch analysis from position: 34
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
Branch analysis from position: 37
2 jumps found. (Code = 43) Position 1 = 44, Position 2 = 45
Branch analysis from position: 44
2 jumps found. (Code = 43) Position 1 = 47, Position 2 = 48
Branch analysis from position: 47
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
Branch analysis from position: 48
Branch analysis from position: 45
Branch analysis from position: 37
Branch analysis from position: 49
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 49
Branch analysis from position: 16
Branch analysis from position: 51
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 51
filename:       /in/oYVkF
function name:  doopScooper
number of ops:  54
compiled vars:  !0 = $dataArray, !1 = $uniqueKeys, !2 = $row, !3 = $checkArray, !4 = $key, !5 = $checkArrayString, !6 = $matchcount, !7 = $array, !8 = $id, !9 = $currentArray, !10 = $currentArrayString
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2      > FE_RESET_R                                       $11     !0, ->51
          3    > > FE_FETCH_R                                               $11, !2, ->51
    5     4    >   ASSIGN                                                   !3, <array>
    6     5      > FE_RESET_R                                       $13     !1, ->16
          6    > > FE_FETCH_R                                               $13, !4, ->16
    7     7    >   ISSET_ISEMPTY_DIM_OBJ                         0          !2, !4
          8      > JMPZ                                                     ~15, ->12
          9    >   FETCH_DIM_R                                      ~16     !2, !4
         10        QM_ASSIGN                                        ~17     ~16
         11      > JMP                                                      ->13
         12    >   QM_ASSIGN                                        ~17     null
         13    >   ASSIGN_DIM                                               !3, !4
         14        OP_DATA                                                  ~17
    6    15      > JMP                                                      ->6
         16    >   FE_FREE                                                  $13
    8    17        INIT_FCALL                                               'json_encode'
         18        SEND_VAR                                                 !3
         19        DO_ICALL                                         $18     
         20        ASSIGN                                                   !5, $18
    9    21        ASSIGN                                                   !6, 0
   10    22      > FE_RESET_R                                       $21     !0, ->49
         23    > > FE_FETCH_R                                       ~22     $21, !7, ->49
         24    >   ASSIGN                                                   !8, ~22
   11    25        ASSIGN                                                   !9, <array>
   12    26      > FE_RESET_R                                       $25     !1, ->37
         27    > > FE_FETCH_R                                               $25, !4, ->37
   13    28    >   ISSET_ISEMPTY_DIM_OBJ                         0          !7, !4
         29      > JMPZ                                                     ~27, ->33
         30    >   FETCH_DIM_R                                      ~28     !7, !4
         31        QM_ASSIGN                                        ~29     ~28
         32      > JMP                                                      ->34
         33    >   QM_ASSIGN                                        ~29     null
         34    >   ASSIGN_DIM                                               !9, !4
         35        OP_DATA                                                  ~29
   12    36      > JMP                                                      ->27
         37    >   FE_FREE                                                  $25
   14    38        INIT_FCALL                                               'json_encode'
         39        SEND_VAR                                                 !9
         40        DO_ICALL                                         $30     
         41        ASSIGN                                                   !10, $30
   15    42        IS_EQUAL                                                 !10, !5
         43      > JMPZ                                                     ~32, ->45
         44    >   PRE_INC                                                  !6
   16    45    >   IS_SMALLER                                               1, !6
         46      > JMPZ                                                     ~34, ->48
         47    >   UNSET_DIM                                                !0, !8
   10    48    > > JMP                                                      ->23
         49    >   FE_FREE                                                  $21
    4    50      > JMP                                                      ->3
         51    >   FE_FREE                                                  $11
   19    52      > RETURN                                                   !0
   20    53*     > RETURN                                                   null

End of function doopscooper

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.78 ms | 1398 KiB | 18 Q