3v4l.org

run code in 300+ PHP versions simultaneously
<?php $posts = range(1, 10); // Collect all of your posts into an array, as an example I'm just using numbers. $posts_reordered = ['left' => [], 'middle' => [], 'right' => []]; foreach(array_chunk($posts, 3) as $chunk) { $posts_reordered['left'][] = $chunk[0]; if(isset($chunk[1])) { $posts_reordered['middle'][] = $chunk[1]; } if(isset($chunk[2])) { $posts_reordered['right'][] = $chunk[2]; } } // Now, print HTML $i = 1; foreach($posts_reordered as $key => $column_posts) { $outer_div_class = ".$key"; // .left echo "<div class='$outer_div_class'>\n"; foreach($column_posts as $post) { $inner_div_class = ".col$i"; echo "\t<div class='$inner_div_class'>$post</div>\n\n"; } echo "</div>\n"; $i++; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 11, Position 2 = 29
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 29
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 22
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 28
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 28
Branch analysis from position: 22
Branch analysis from position: 29
2 jumps found. (Code = 77) Position 1 = 32, Position 2 = 57
Branch analysis from position: 32
2 jumps found. (Code = 78) Position 1 = 33, Position 2 = 57
Branch analysis from position: 33
2 jumps found. (Code = 77) Position 1 = 42, Position 2 = 53
Branch analysis from position: 42
2 jumps found. (Code = 78) Position 1 = 43, Position 2 = 53
Branch analysis from position: 43
1 jumps found. (Code = 42) Position 1 = 42
Branch analysis from position: 42
Branch analysis from position: 53
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
Branch analysis from position: 53
Branch analysis from position: 57
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 57
Branch analysis from position: 29
filename:       /in/kUX8Z
function name:  (null)
number of ops:  59
compiled vars:  !0 = $posts, !1 = $posts_reordered, !2 = $chunk, !3 = $i, !4 = $column_posts, !5 = $key, !6 = $outer_div_class, !7 = $post, !8 = $inner_div_class
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'range'
          1        SEND_VAL                                                 1
          2        SEND_VAL                                                 10
          3        DO_ICALL                                         $9      
          4        ASSIGN                                                   !0, $9
    5     5        ASSIGN                                                   !1, <array>
    7     6        INIT_FCALL                                               'array_chunk'
          7        SEND_VAR                                                 !0
          8        SEND_VAL                                                 3
          9        DO_ICALL                                         $12     
         10      > FE_RESET_R                                       $13     $12, ->29
         11    > > FE_FETCH_R                                               $13, !2, ->29
    8    12    >   FETCH_DIM_R                                      ~16     !2, 0
         13        FETCH_DIM_W                                      $14     !1, 'left'
         14        ASSIGN_DIM                                               $14
         15        OP_DATA                                                  ~16
    9    16        ISSET_ISEMPTY_DIM_OBJ                         0          !2, 1
         17      > JMPZ                                                     ~17, ->22
   10    18    >   FETCH_DIM_R                                      ~20     !2, 1
         19        FETCH_DIM_W                                      $18     !1, 'middle'
         20        ASSIGN_DIM                                               $18
         21        OP_DATA                                                  ~20
   12    22    >   ISSET_ISEMPTY_DIM_OBJ                         0          !2, 2
         23      > JMPZ                                                     ~21, ->28
   13    24    >   FETCH_DIM_R                                      ~24     !2, 2
         25        FETCH_DIM_W                                      $22     !1, 'right'
         26        ASSIGN_DIM                                               $22
         27        OP_DATA                                                  ~24
    7    28    > > JMP                                                      ->11
         29    >   FE_FREE                                                  $13
   19    30        ASSIGN                                                   !3, 1
   20    31      > FE_RESET_R                                       $26     !1, ->57
         32    > > FE_FETCH_R                                       ~27     $26, !4, ->57
         33    >   ASSIGN                                                   !5, ~27
   21    34        NOP                                                      
         35        FAST_CONCAT                                      ~29     '.', !5
         36        ASSIGN                                                   !6, ~29
   23    37        ROPE_INIT                                     3  ~32     '%3Cdiv+class%3D%27'
         38        ROPE_ADD                                      1  ~32     ~32, !6
         39        ROPE_END                                      2  ~31     ~32, '%27%3E%0A'
         40        ECHO                                                     ~31
   25    41      > FE_RESET_R                                       $34     !4, ->53
         42    > > FE_FETCH_R                                               $34, !7, ->53
   26    43    >   NOP                                                      
         44        FAST_CONCAT                                      ~35     '.col', !3
         45        ASSIGN                                                   !8, ~35
   27    46        ROPE_INIT                                     5  ~38     '%09%3Cdiv+class%3D%27'
         47        ROPE_ADD                                      1  ~38     ~38, !8
         48        ROPE_ADD                                      2  ~38     ~38, '%27%3E'
         49        ROPE_ADD                                      3  ~38     ~38, !7
         50        ROPE_END                                      4  ~37     ~38, '%3C%2Fdiv%3E%0A%0A'
         51        ECHO                                                     ~37
   25    52      > JMP                                                      ->42
         53    >   FE_FREE                                                  $34
   30    54        ECHO                                                     '%3C%2Fdiv%3E%0A'
   31    55        PRE_INC                                                  !3
   20    56      > JMP                                                      ->32
         57    >   FE_FREE                                                  $26
   32    58      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.82 ms | 1016 KiB | 15 Q