3v4l.org

run code in 500+ PHP versions simultaneously
<?php $arrayA = [ ["sentence" => "Hello world", "nextSpeaker" => 0], ["sentence" => "Hello world again", "nextSpeaker" => 1], ["sentence" => "Hello world twice!", "nextSpeaker" => 1], ]; $arrayB = [ ["sentence" => "Bye world", "nextSpeaker" => 1], ["sentence" => "Bye world again", "nextSpeaker" => 0], ["sentence" => "Bye world twice", "nextSpeaker" => 0], ]; $arrays = [$arrayA, $arrayB]; $pullFrom = 0; $result = []; while ($arrays[0] && $arrays[1]) { $result[] = $row = array_shift($arrays[$pullFrom]); $pullFrom = $row['nextSpeaker'] ? 1 - $pullFrom : $pullFrom; } var_export(array_merge($result, ...$arrays));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
2 jumps found. (Code = 46) Position 1 = 24, Position 2 = 26
Branch analysis from position: 24
2 jumps found. (Code = 44) Position 1 = 27, Position 2 = 8
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 20
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
2 jumps found. (Code = 46) Position 1 = 24, Position 2 = 26
Branch analysis from position: 24
Branch analysis from position: 26
Branch analysis from position: 20
2 jumps found. (Code = 46) Position 1 = 24, Position 2 = 26
Branch analysis from position: 24
Branch analysis from position: 26
Branch analysis from position: 26
filename:       /in/HMpgI
function name:  (null)
number of ops:  36
compiled vars:  !0 = $arrayA, !1 = $arrayB, !2 = $arrays, !3 = $pullFrom, !4 = $result, !5 = $row
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
    9     1        ASSIGN                                                       !1, <array>
   15     2        INIT_ARRAY                                           ~8      !0
          3        ADD_ARRAY_ELEMENT                                    ~8      !1
          4        ASSIGN                                                       !2, ~8
   16     5        ASSIGN                                                       !3, 0
   17     6        ASSIGN                                                       !4, <array>
   18     7      > JMP                                                          ->22
   19     8    >   INIT_FCALL                                                   'array_shift'
          9        FETCH_DIM_W                                          $13     !2, !3
         10        SEND_REF                                                     $13
         11        DO_ICALL                                             $14     
         12        ASSIGN                                               ~15     !5, $14
         13        ASSIGN_DIM                                                   !4
         14        OP_DATA                                                      ~15
   20    15        FETCH_DIM_R                                          ~16     !5, 'nextSpeaker'
         16      > JMPZ                                                         ~16, ->20
         17    >   SUB                                                  ~17     1, !3
         18        QM_ASSIGN                                            ~18     ~17
         19      > JMP                                                          ->21
         20    >   QM_ASSIGN                                            ~18     !3
         21    >   ASSIGN                                                       !3, ~18
   18    22    >   FETCH_DIM_R                                          ~20     !2, 0
         23      > JMPZ_EX                                              ~20     ~20, ->26
         24    >   FETCH_DIM_R                                          ~21     !2, 1
         25        BOOL                                                 ~20     ~21
         26    > > JMPNZ                                                        ~20, ->8
   23    27    >   INIT_FCALL                                                   'var_export'
         28        INIT_FCALL                                                   'array_merge'
         29        SEND_VAR                                                     !4
         30        SEND_UNPACK                                                  !2
         31        CHECK_UNDEF_ARGS                                             
         32        DO_ICALL                                             $22     
         33        SEND_VAR                                                     $22
         34        DO_ICALL                                                     
         35      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
201.12 ms | 1996 KiB | 16 Q