3v4l.org

run code in 300+ PHP versions simultaneously
<?php function P(array $sources) { $result=array(); $cache=array(); foreach($sources as $node) { $cache=$result; $result=array(); foreach($node as $item) { if(empty($cache)) { $result[]=array($item); } else { foreach($cache as $line) { $line[]=$item; $result[]=$line; } } } } return $result; } $result=P(array( array('a', 'b'), array('a', 'b'), array('a', 'b'), array('a'), array('a'), array('a') )); print_r(array_map(function($a){return implode(",",$a);},$result));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/AHl0u
function name:  (null)
number of ops:  13
compiled vars:  !0 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   INIT_FCALL                                               'p'
          1        SEND_VAL                                                 <array>
          2        DO_FCALL                                      0  $1      
          3        ASSIGN                                                   !0, $1
   29     4        INIT_FCALL                                               'print_r'
          5        INIT_FCALL                                               'array_map'
          6        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FAHl0u%3A29%240'
          7        SEND_VAL                                                 ~3
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                         $4      
         10        SEND_VAR                                                 $4
         11        DO_ICALL                                                 
         12      > RETURN                                                   1

Function p:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 26
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 26
Branch analysis from position: 5
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 24
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 24
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 15
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 15
2 jumps found. (Code = 77) Position 1 = 16, Position 2 = 22
Branch analysis from position: 16
2 jumps found. (Code = 78) Position 1 = 17, Position 2 = 22
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 22
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 24
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
filename:       /in/AHl0u
function name:  P
number of ops:  29
compiled vars:  !0 = $sources, !1 = $result, !2 = $cache, !3 = $node, !4 = $item, !5 = $line
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    4     1        ASSIGN                                                   !1, <array>
    5     2        ASSIGN                                                   !2, <array>
    6     3      > FE_RESET_R                                       $8      !0, ->26
          4    > > FE_FETCH_R                                               $8, !3, ->26
    8     5    >   ASSIGN                                                   !2, !1
    9     6        ASSIGN                                                   !1, <array>
   10     7      > FE_RESET_R                                       $11     !3, ->24
          8    > > FE_FETCH_R                                               $11, !4, ->24
   12     9    >   ISSET_ISEMPTY_CV                                         !2
         10      > JMPZ                                                     ~12, ->15
   14    11    >   INIT_ARRAY                                       ~14     !4
         12        ASSIGN_DIM                                               !1
         13        OP_DATA                                                  ~14
         14      > JMP                                                      ->23
   18    15    > > FE_RESET_R                                       $15     !2, ->22
         16    > > FE_FETCH_R                                               $15, !5, ->22
   20    17    >   ASSIGN_DIM                                               !5
         18        OP_DATA                                                  !4
   21    19        ASSIGN_DIM                                               !1
         20        OP_DATA                                                  !5
   18    21      > JMP                                                      ->16
         22    >   FE_FREE                                                  $15
   10    23    > > JMP                                                      ->8
         24    >   FE_FREE                                                  $11
    6    25      > JMP                                                      ->4
         26    >   FE_FREE                                                  $8
   26    27      > RETURN                                                   !1
   27    28*     > RETURN                                                   null

End of function p

Function %00%7Bclosure%7D%2Fin%2FAHl0u%3A29%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/AHl0u
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   RECV                                             !0      
          1        INIT_FCALL                                               'implode'
          2        SEND_VAL                                                 '%2C'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $1      
          5      > RETURN                                                   $1
          6*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FAHl0u%3A29%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.87 ms | 1394 KiB | 20 Q