3v4l.org

run code in 500+ PHP versions simultaneously
<?php $arr = [ [ 'foo 1', 'bar 1', '', '', 'test 1', 'lorem 1', 'ipsum 1', '', 'will be ignored 1', ], [ 'foo 2', 'bar 2', '', '', 'test 2', 'lorem 2', 'ipsum 2', '', 'will be ignored 2', ], [ 'foo 3', 'bar 3', '', '', 'test 3', 'lorem 3', 'ipsum 3', '', 'will be ignored 3', ], [ 'foo 4', 'bar 4', '', '', 'test 4', 'lorem 4', 'ipsum 4', '', 'will be ignored 4', ], ]; $newArray = []; foreach($arr as $sub) { // The example array you say you want have 8 elements, indexes 0-7 $newArray[] = array_slice($sub, 0, 8); } print_r($newArray);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 12
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 12
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
filename:       /in/WhFm4
function name:  (null)
number of ops:  17
compiled vars:  !0 = $arr, !1 = $newArray, !2 = $sub
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                       !0, <array>
   50     1        ASSIGN                                                       !1, <array>
   52     2      > FE_RESET_R                                           $5      !0, ->12
          3    > > FE_FETCH_R                                                   $5, !2, ->12
   54     4    >   INIT_FCALL                                                   'array_slice'
          5        SEND_VAR                                                     !2
          6        SEND_VAL                                                     0
          7        SEND_VAL                                                     8
          8        DO_ICALL                                             $7      
          9        ASSIGN_DIM                                                   !1
         10        OP_DATA                                                      $7
   52    11      > JMP                                                          ->3
         12    >   FE_FREE                                                      $5
   57    13        INIT_FCALL                                                   'print_r'
         14        SEND_VAR                                                     !1
         15        DO_ICALL                                                     
         16      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
163.67 ms | 2074 KiB | 15 Q