3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = range(1, 18); // You can either index by 0 and add one, or 1 and subtract one for($i = 1; $i <= count($data); $i++) { // Variable for easier reference later $item = $data[$i - 1]; // On the fifth item, emit logic for just one if(0 === $i % 5){ echo 'Single: ' . $item; }else { // Grab the next if it exsts $next = $data[$i++] ?? null; if($next){ echo 'Double: ' . $item . ', ' . $next; }else{ echo 'Double: ' . $item; } } echo PHP_EOL; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
2 jumps found. (Code = 44) Position 1 = 34, Position 2 = 7
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 16
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
2 jumps found. (Code = 44) Position 1 = 34, Position 2 = 7
Branch analysis from position: 34
Branch analysis from position: 7
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 27
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
Branch analysis from position: 27
2 jumps found. (Code = 44) Position 1 = 34, Position 2 = 7
Branch analysis from position: 34
Branch analysis from position: 7
filename:       /in/LA46Y
function name:  (null)
number of ops:  35
compiled vars:  !0 = $data, !1 = $i, !2 = $item, !3 = $next
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'range'
          1        SEND_VAL                                                 1
          2        SEND_VAL                                                 18
          3        DO_ICALL                                         $4      
          4        ASSIGN                                                   !0, $4
    6     5        ASSIGN                                                   !1, 1
          6      > JMP                                                      ->31
    9     7    >   SUB                                              ~7      !1, 1
          8        FETCH_DIM_R                                      ~8      !0, ~7
          9        ASSIGN                                                   !2, ~8
   12    10        MOD                                              ~10     !1, 5
         11        IS_IDENTICAL                                             ~10, 0
         12      > JMPZ                                                     ~11, ->16
   13    13    >   CONCAT                                           ~12     'Single%3A+', !2
         14        ECHO                                                     ~12
   12    15      > JMP                                                      ->29
   17    16    >   POST_INC                                         ~13     !1
         17        FETCH_DIM_IS                                     ~14     !0, ~13
         18        COALESCE                                         ~15     ~14
         19        QM_ASSIGN                                        ~15     null
         20        ASSIGN                                                   !3, ~15
   18    21      > JMPZ                                                     !3, ->27
   19    22    >   CONCAT                                           ~17     'Double%3A+', !2
         23        CONCAT                                           ~18     ~17, '%2C+'
         24        CONCAT                                           ~19     ~18, !3
         25        ECHO                                                     ~19
   18    26      > JMP                                                      ->29
   21    27    >   CONCAT                                           ~20     'Double%3A+', !2
         28        ECHO                                                     ~20
   25    29    >   ECHO                                                     '%0A'
    6    30        PRE_INC                                                  !1
         31    >   COUNT                                            ~22     !0
         32        IS_SMALLER_OR_EQUAL                                      !1, ~22
         33      > JMPNZ                                                    ~23, ->7
   26    34    > > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
139.43 ms | 1005 KiB | 14 Q