3v4l.org

run code in 500+ PHP versions simultaneously
<?php $arr = [2,5,1,12,-5,4,-1,3,-3,20,8,7,-2,6,9]; $a = $arr; asort($a); $a = array_chunk($a, 5); $output = []; $idx = 0; while($a){ if($idx++ % 2){ $b = array_pop($a); arsort($b); }else{ $b = array_shift($a); } $output = array_merge($output, $b); } var_dump($output);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
2 jumps found. (Code = 44) Position 1 = 34, Position 2 = 13
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 24
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
2 jumps found. (Code = 44) Position 1 = 34, Position 2 = 13
Branch analysis from position: 34
Branch analysis from position: 13
Branch analysis from position: 24
2 jumps found. (Code = 44) Position 1 = 34, Position 2 = 13
Branch analysis from position: 34
Branch analysis from position: 13
filename:       /in/KGgWI
function name:  (null)
number of ops:  38
compiled vars:  !0 = $arr, !1 = $a, !2 = $output, !3 = $idx, !4 = $b
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
    4     1        ASSIGN                                                       !1, !0
    5     2        INIT_FCALL                                                   'asort'
          3        SEND_REF                                                     !1
          4        DO_ICALL                                                     
    7     5        INIT_FCALL                                                   'array_chunk'
          6        SEND_VAR                                                     !1
          7        SEND_VAL                                                     5
          8        DO_ICALL                                             $8      
          9        ASSIGN                                                       !1, $8
    9    10        ASSIGN                                                       !2, <array>
   10    11        ASSIGN                                                       !3, 0
   11    12      > JMP                                                          ->33
   12    13    >   POST_INC                                             ~12     !3
         14        MOD                                                  ~13     ~12, 2
         15      > JMPZ                                                         ~13, ->24
   13    16    >   INIT_FCALL                                                   'array_pop'
         17        SEND_REF                                                     !1
         18        DO_ICALL                                             $14     
         19        ASSIGN                                                       !4, $14
   14    20        INIT_FCALL                                                   'arsort'
         21        SEND_REF                                                     !4
         22        DO_ICALL                                                     
   12    23      > JMP                                                          ->28
   16    24    >   INIT_FCALL                                                   'array_shift'
         25        SEND_REF                                                     !1
         26        DO_ICALL                                             $17     
         27        ASSIGN                                                       !4, $17
   18    28    >   INIT_FCALL                                                   'array_merge'
         29        SEND_VAR                                                     !2
         30        SEND_VAR                                                     !4
         31        DO_ICALL                                             $19     
         32        ASSIGN                                                       !2, $19
   11    33    > > JMPNZ                                                        !1, ->13
   21    34    >   INIT_FCALL                                                   'var_dump'
         35        SEND_VAR                                                     !2
         36        DO_ICALL                                                     
         37      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
171.15 ms | 2091 KiB | 20 Q