3v4l.org

run code in 300+ PHP versions simultaneously
<?php define('PER_ROW', 3); $resultset[] = array('id' => 3, 'name' => 'Bob'); $resultset[] = array('id' => 5, 'name' => 'Mark'); $resultset[] = array('id' => 9, 'name' => 'Sam'); $resultset[] = array('id' => 10, 'name' => 'Linda'); $resultset[] = array('id' => 11, 'name' => 'Amy'); $resultset[] = array('id' => 75, 'name' => 'John'); $resultset[] = array('id' => 20, 'name' => 'Aaron'); $resultset[] = array('id' => 19, 'name' => 'Ringo'); $resultset[] = array('id' => 2, 'name' => 'Paul'); $resultset[] = array('id' => 99, 'name' => 'George'); foreach ($resultset as $key => $row) { $key++; if ($key % PER_ROW === 1) { // First item in row echo "| "; } echo "{$row['id']}: {$row['name']} | "; if ($key % PER_ROW === 0) { // Last item in row echo PHP_EOL; } } echo PHP_EOL;
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 25, Position 2 = 46
Branch analysis from position: 25
2 jumps found. (Code = 78) Position 1 = 26, Position 2 = 46
Branch analysis from position: 26
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 33
Branch analysis from position: 32
2 jumps found. (Code = 43) Position 1 = 44, Position 2 = 45
Branch analysis from position: 44
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
Branch analysis from position: 45
Branch analysis from position: 33
Branch analysis from position: 46
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 46
filename:       /in/lD83M
function name:  (null)
number of ops:  49
compiled vars:  !0 = $resultset, !1 = $row, !2 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'define'
          1        SEND_VAL                                                 'PER_ROW'
          2        SEND_VAL                                                 3
          3        DO_ICALL                                                 
    5     4        ASSIGN_DIM                                               !0
          5        OP_DATA                                                  <array>
    6     6        ASSIGN_DIM                                               !0
          7        OP_DATA                                                  <array>
    7     8        ASSIGN_DIM                                               !0
          9        OP_DATA                                                  <array>
    8    10        ASSIGN_DIM                                               !0
         11        OP_DATA                                                  <array>
    9    12        ASSIGN_DIM                                               !0
         13        OP_DATA                                                  <array>
   10    14        ASSIGN_DIM                                               !0
         15        OP_DATA                                                  <array>
   11    16        ASSIGN_DIM                                               !0
         17        OP_DATA                                                  <array>
   12    18        ASSIGN_DIM                                               !0
         19        OP_DATA                                                  <array>
   13    20        ASSIGN_DIM                                               !0
         21        OP_DATA                                                  <array>
   14    22        ASSIGN_DIM                                               !0
         23        OP_DATA                                                  <array>
   18    24      > FE_RESET_R                                       $14     !0, ->46
         25    > > FE_FETCH_R                                       ~15     $14, !1, ->46
         26    >   ASSIGN                                                   !2, ~15
   19    27        PRE_INC                                                  !2
   21    28        FETCH_CONSTANT                                   ~18     'PER_ROW'
         29        MOD                                              ~19     !2, ~18
         30        IS_IDENTICAL                                             ~19, 1
         31      > JMPZ                                                     ~20, ->33
   23    32    >   ECHO                                                     '%7C+'
   25    33    >   FETCH_DIM_R                                      ~21     !1, 'id'
         34        ROPE_INIT                                     4  ~24     ~21
         35        ROPE_ADD                                      1  ~24     ~24, '%3A+'
         36        FETCH_DIM_R                                      ~22     !1, 'name'
         37        ROPE_ADD                                      2  ~24     ~24, ~22
         38        ROPE_END                                      3  ~23     ~24, '+%7C+'
         39        ECHO                                                     ~23
   27    40        FETCH_CONSTANT                                   ~26     'PER_ROW'
         41        MOD                                              ~27     !2, ~26
         42        IS_IDENTICAL                                             ~27, 0
         43      > JMPZ                                                     ~28, ->45
   29    44    >   ECHO                                                     '%0A'
   18    45    > > JMP                                                      ->25
         46    >   FE_FREE                                                  $14
   33    47        ECHO                                                     '%0A'
   34    48      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
126.34 ms | 1405 KiB | 15 Q