3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = array(15, 10, 12, 17, 21, 13, 15, 25, 7, 18, 4, 1, 5, 2); $chunks = array_chunk($arr, 3); $ids = array(); foreach ($chunks as $k => $v) { $otherIds = array(6, 7, 22, 31, 44, 9, 17); $ids = $v; foreach ($chunks as $key => $val) { if ($key <= $k) continue; foreach ($chunks[$key] as $g => $ch) { foreach ($otherIds as $o) { if ($ch['id'] == $o) { $ids[] = $o; unset($chunks[$key][$g]); } } } } } print_r($chunks); print_r($ids);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 38
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 38
Branch analysis from position: 9
2 jumps found. (Code = 77) Position 1 = 13, Position 2 = 36
Branch analysis from position: 13
2 jumps found. (Code = 78) Position 1 = 14, Position 2 = 36
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 18
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 18
2 jumps found. (Code = 77) Position 1 = 20, Position 2 = 34
Branch analysis from position: 20
2 jumps found. (Code = 78) Position 1 = 21, Position 2 = 34
Branch analysis from position: 21
2 jumps found. (Code = 77) Position 1 = 23, Position 2 = 32
Branch analysis from position: 23
2 jumps found. (Code = 78) Position 1 = 24, Position 2 = 32
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 31
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
Branch analysis from position: 31
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
Branch analysis from position: 32
Branch analysis from position: 34
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 34
Branch analysis from position: 36
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 36
Branch analysis from position: 38
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 38
filename:       /in/8HJD5
function name:  (null)
number of ops:  46
compiled vars:  !0 = $arr, !1 = $chunks, !2 = $ids, !3 = $v, !4 = $k, !5 = $otherIds, !6 = $val, !7 = $key, !8 = $ch, !9 = $g, !10 = $o
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    5     1        INIT_FCALL                                               'array_chunk'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 3
          4        DO_ICALL                                         $12     
          5        ASSIGN                                                   !1, $12
    6     6        ASSIGN                                                   !2, <array>
    7     7      > FE_RESET_R                                       $15     !1, ->38
          8    > > FE_FETCH_R                                       ~16     $15, !3, ->38
          9    >   ASSIGN                                                   !4, ~16
    8    10        ASSIGN                                                   !5, <array>
    9    11        ASSIGN                                                   !2, !3
   11    12      > FE_RESET_R                                       $20     !1, ->36
         13    > > FE_FETCH_R                                       ~21     $20, !6, ->36
         14    >   ASSIGN                                                   !7, ~21
   12    15        IS_SMALLER_OR_EQUAL                                      !7, !4
         16      > JMPZ                                                     ~23, ->18
         17    > > JMP                                                      ->13
   13    18    >   FETCH_DIM_R                                      ~24     !1, !7
         19      > FE_RESET_R                                       $25     ~24, ->34
         20    > > FE_FETCH_R                                       ~26     $25, !8, ->34
         21    >   ASSIGN                                                   !9, ~26
   14    22      > FE_RESET_R                                       $28     !5, ->32
         23    > > FE_FETCH_R                                               $28, !10, ->32
   15    24    >   FETCH_DIM_R                                      ~29     !8, 'id'
         25        IS_EQUAL                                                 !10, ~29
         26      > JMPZ                                                     ~30, ->31
   16    27    >   ASSIGN_DIM                                               !2
         28        OP_DATA                                                  !10
   17    29        FETCH_DIM_UNSET                                  $32     !1, !7
         30        UNSET_DIM                                                $32, !9
   14    31    > > JMP                                                      ->23
         32    >   FE_FREE                                                  $28
   13    33      > JMP                                                      ->20
         34    >   FE_FREE                                                  $25
   11    35      > JMP                                                      ->13
         36    >   FE_FREE                                                  $20
    7    37      > JMP                                                      ->8
         38    >   FE_FREE                                                  $15
   24    39        INIT_FCALL                                               'print_r'
         40        SEND_VAR                                                 !1
         41        DO_ICALL                                                 
   25    42        INIT_FCALL                                               'print_r'
         43        SEND_VAR                                                 !2
         44        DO_ICALL                                                 
         45      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.97 ms | 1400 KiB | 17 Q