3v4l.org

run code in 300+ PHP versions simultaneously
<?php $balls = [['001', '001', '003', '004', '005'], ['012', '004', '007', '010', '005'], ['011', '007', '009', '008', '005']]; $searchMatches = function($balls) { foreach ($balls as $rowNumber => $rowData) { $repeating = array_filter(array_count_values($rowData), function ($count) { return $count > 1; }); if ($repeating) { $tmpRow = $rowData; foreach ($repeating as $value => $count) { for ($i = 1; $i <= $count; $i++) { $index = array_search($value, $tmpRow); $matchesRow[$rowNumber][$index] = $value; unset($tmpRow[$index]); } } } } return $matchesRow; }; $reverseBalls = []; foreach($balls as $rowNumber => $rowData) { $count = count($rowData); for($i = 0; $i < $count; $i++) { $reverseBalls[$i][$rowNumber] = $rowData[$i]; } } var_dump($searchMatches($balls)); var_dump($searchMatches($reverseBalls));
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 19
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 19
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 11
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 11
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 11
Branch analysis from position: 18
Branch analysis from position: 11
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
filename:       /in/vST6v
function name:  (null)
number of ops:  33
compiled vars:  !0 = $balls, !1 = $searchMatches, !2 = $reverseBalls, !3 = $rowData, !4 = $rowNumber, !5 = $count, !6 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    7     1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FvST6v%3A7%240'
          2        ASSIGN                                                   !1, ~8
   26     3        ASSIGN                                                   !2, <array>
   27     4      > FE_RESET_R                                       $11     !0, ->19
          5    > > FE_FETCH_R                                       ~12     $11, !3, ->19
          6    >   ASSIGN                                                   !4, ~12
   29     7        COUNT                                            ~14     !3
          8        ASSIGN                                                   !5, ~14
   30     9        ASSIGN                                                   !6, 0
         10      > JMP                                                      ->16
   32    11    >   FETCH_DIM_R                                      ~19     !3, !6
         12        FETCH_DIM_W                                      $17     !2, !6
         13        ASSIGN_DIM                                               $17, !4
         14        OP_DATA                                                  ~19
   30    15        PRE_INC                                                  !6
         16    >   IS_SMALLER                                               !6, !5
         17      > JMPNZ                                                    ~21, ->11
   27    18    > > JMP                                                      ->5
         19    >   FE_FREE                                                  $11
   37    20        INIT_FCALL                                               'var_dump'
         21        INIT_DYNAMIC_CALL                                        !1
         22        SEND_VAR_EX                                              !0
         23        DO_FCALL                                      0  $22     
         24        SEND_VAR                                                 $22
         25        DO_ICALL                                                 
   38    26        INIT_FCALL                                               'var_dump'
         27        INIT_DYNAMIC_CALL                                        !1
         28        SEND_VAR_EX                                              !2
         29        DO_FCALL                                      0  $24     
         30        SEND_VAR                                                 $24
         31        DO_ICALL                                                 
         32      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FvST6v%3A7%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 35
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 35
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 34
Branch analysis from position: 14
2 jumps found. (Code = 77) Position 1 = 16, Position 2 = 33
Branch analysis from position: 16
2 jumps found. (Code = 78) Position 1 = 17, Position 2 = 33
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
2 jumps found. (Code = 44) Position 1 = 32, Position 2 = 20
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
Branch analysis from position: 20
2 jumps found. (Code = 44) Position 1 = 32, Position 2 = 20
Branch analysis from position: 32
Branch analysis from position: 20
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 33
Branch analysis from position: 34
Branch analysis from position: 35
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 35
filename:       /in/vST6v
function name:  {closure}
number of ops:  38
compiled vars:  !0 = $balls, !1 = $rowData, !2 = $rowNumber, !3 = $repeating, !4 = $tmpRow, !5 = $count, !6 = $value, !7 = $i, !8 = $index, !9 = $matchesRow
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    8     1      > FE_RESET_R                                       $10     !0, ->35
          2    > > FE_FETCH_R                                       ~11     $10, !1, ->35
          3    >   ASSIGN                                                   !2, ~11
    9     4        INIT_FCALL                                               'array_filter'
          5        INIT_FCALL                                               'array_count_values'
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                         $13     
          8        SEND_VAR                                                 $13
          9        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FvST6v%3A9%241'
   11    10        SEND_VAL                                                 ~14
         11        DO_ICALL                                         $15     
    9    12        ASSIGN                                                   !3, $15
   12    13      > JMPZ                                                     !3, ->34
   13    14    >   ASSIGN                                                   !4, !1
   14    15      > FE_RESET_R                                       $18     !3, ->33
         16    > > FE_FETCH_R                                       ~19     $18, !5, ->33
         17    >   ASSIGN                                                   !6, ~19
   15    18        ASSIGN                                                   !7, 1
         19      > JMP                                                      ->30
   16    20    >   INIT_FCALL                                               'array_search'
         21        SEND_VAR                                                 !6
         22        SEND_VAR                                                 !4
         23        DO_ICALL                                         $22     
         24        ASSIGN                                                   !8, $22
   17    25        FETCH_DIM_W                                      $24     !9, !2
         26        ASSIGN_DIM                                               $24, !8
         27        OP_DATA                                                  !6
   18    28        UNSET_DIM                                                !4, !8
   15    29        PRE_INC                                                  !7
         30    >   IS_SMALLER_OR_EQUAL                                      !7, !5
         31      > JMPNZ                                                    ~27, ->20
   14    32    > > JMP                                                      ->16
         33    >   FE_FREE                                                  $18
    8    34    > > JMP                                                      ->2
         35    >   FE_FREE                                                  $10
   23    36      > RETURN                                                   !9
   24    37*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FvST6v%3A7%240

Function %00%7Bclosure%7D%2Fin%2FvST6v%3A9%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vST6v
function name:  {closure}
number of ops:  4
compiled vars:  !0 = $count
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
   10     1        IS_SMALLER                                       ~1      1, !0
          2      > RETURN                                                   ~1
   11     3*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FvST6v%3A9%241

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
175.82 ms | 1404 KiB | 21 Q