3v4l.org

run code in 300+ PHP versions simultaneously
<?php $leaders = [1,4,8,13]; $members = [2,3,5,6,7,9,10,11,12]; $result = []; $lastMember = null; foreach ($members as $member) { if ($lastMember === null || $lastMember !== $member - 1) { unset($ref); $result[array_shift($leaders)] = &$ref; } $ref[] = $lastMember = $member; } foreach ($leaders as $leader) { $result[$member] = null; } var_export($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 22
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 22
Branch analysis from position: 6
2 jumps found. (Code = 47) Position 1 = 8, Position 2 = 11
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 18
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 18
Branch analysis from position: 11
Branch analysis from position: 22
2 jumps found. (Code = 77) Position 1 = 24, Position 2 = 28
Branch analysis from position: 24
2 jumps found. (Code = 78) Position 1 = 25, Position 2 = 28
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
Branch analysis from position: 22
filename:       /in/hfDAN
function name:  (null)
number of ops:  33
compiled vars:  !0 = $leaders, !1 = $members, !2 = $result, !3 = $lastMember, !4 = $member, !5 = $ref, !6 = $leader
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        ASSIGN                                                   !1, <array>
    6     2        ASSIGN                                                   !2, <array>
    7     3        ASSIGN                                                   !3, null
    8     4      > FE_RESET_R                                       $11     !1, ->22
          5    > > FE_FETCH_R                                               $11, !4, ->22
    9     6    >   TYPE_CHECK                                    2  ~12     !3
          7      > JMPNZ_EX                                         ~12     ~12, ->11
          8    >   SUB                                              ~13     !4, 1
          9        IS_NOT_IDENTICAL                                 ~14     !3, ~13
         10        BOOL                                             ~12     ~14
         11    > > JMPZ                                                     ~12, ->18
   10    12    >   UNSET_CV                                                 !5
   11    13        INIT_FCALL                                               'array_shift'
         14        SEND_REF                                                 !0
         15        DO_ICALL                                         $15     
         16        FETCH_DIM_W                                      $16     !2, $15
         17        ASSIGN_REF                                               $16, !5
   13    18    >   ASSIGN                                           ~19     !3, !4
         19        ASSIGN_DIM                                               !5
         20        OP_DATA                                                  ~19
    8    21      > JMP                                                      ->5
         22    >   FE_FREE                                                  $11
   15    23      > FE_RESET_R                                       $20     !0, ->28
         24    > > FE_FETCH_R                                               $20, !6, ->28
   16    25    >   ASSIGN_DIM                                               !2, !4
         26        OP_DATA                                                  null
   15    27      > JMP                                                      ->24
         28    >   FE_FREE                                                  $20
   18    29        INIT_FCALL                                               'var_export'
         30        SEND_VAR                                                 !2
         31        DO_ICALL                                                 
         32      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.41 ms | 1016 KiB | 15 Q