3v4l.org

run code in 300+ PHP versions simultaneously
<?php function array_thingy(array $a, array $b) { $output = array(); while (count($a) > 0 || count($b) > 0) { if (count($a) > 0) { array_push($output, array_shift($a)); } if (count($b) > 0) { array_push($output, array_shift($b)); } } return $output; } $a = array( array( 'name' => 'Product 1', 'type' => 'p' ), array( 'name' => 'Product 2', 'type' => 'p' ) ); $b = array( array( 'name' => 'social 1', 'type' => 'f' ), array( 'name' => 'social 2', 'type' => 'f' ), array( 'name' => 'social 3', 'type' => 'f' ), array( 'name' => 'social 4', 'type' => 'f' ), array( 'name' => 'social 5', 'type' => 'f' ) ); var_dump(array_thingy($a, $b));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1rSYV
function name:  (null)
number of ops:  10
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   ASSIGN                                                   !0, <array>
   30     1        ASSIGN                                                   !1, <array>
   54     2        INIT_FCALL                                               'var_dump'
          3        INIT_FCALL                                               'array_thingy'
          4        SEND_VAR                                                 !0
          5        SEND_VAR                                                 !1
          6        DO_FCALL                                      0  $4      
          7        SEND_VAR                                                 $4
          8        DO_ICALL                                                 
          9      > RETURN                                                   1

Function array_thingy:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
2 jumps found. (Code = 47) Position 1 = 27, Position 2 = 30
Branch analysis from position: 27
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 4
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 14
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 24
Branch analysis from position: 17
2 jumps found. (Code = 47) Position 1 = 27, Position 2 = 30
Branch analysis from position: 27
Branch analysis from position: 30
Branch analysis from position: 24
Branch analysis from position: 14
Branch analysis from position: 30
filename:       /in/1rSYV
function name:  array_thingy
number of ops:  33
compiled vars:  !0 = $a, !1 = $b, !2 = $output
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2        ASSIGN                                                   !2, <array>
    6     3      > JMP                                                      ->24
    7     4    >   COUNT                                            ~4      !0
          5        IS_SMALLER                                               0, ~4
          6      > JMPZ                                                     ~5, ->14
    8     7    >   INIT_FCALL                                               'array_push'
          8        SEND_REF                                                 !2
          9        INIT_FCALL                                               'array_shift'
         10        SEND_REF                                                 !0
         11        DO_ICALL                                         $6      
         12        SEND_VAR                                                 $6
         13        DO_ICALL                                                 
   11    14    >   COUNT                                            ~8      !1
         15        IS_SMALLER                                               0, ~8
         16      > JMPZ                                                     ~9, ->24
   12    17    >   INIT_FCALL                                               'array_push'
         18        SEND_REF                                                 !2
         19        INIT_FCALL                                               'array_shift'
         20        SEND_REF                                                 !1
         21        DO_ICALL                                         $10     
         22        SEND_VAR                                                 $10
         23        DO_ICALL                                                 
    6    24    >   COUNT                                            ~12     !0
         25        IS_SMALLER                                       ~13     0, ~12
         26      > JMPNZ_EX                                         ~13     ~13, ->30
         27    >   COUNT                                            ~14     !1
         28        IS_SMALLER                                       ~15     0, ~14
         29        BOOL                                             ~13     ~15
         30    > > JMPNZ                                                    ~13, ->4
   16    31    > > RETURN                                                   !2
   17    32*     > RETURN                                                   null

End of function array_thingy

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.87 ms | 1403 KiB | 20 Q