3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = '<h2>Spiders</h2> <h2>Beetles</h2> <h3>External morphology</h3> <h4>Head</h4> <h4>Thorax</h4> <h4>Legs</h4> <h5>Feet</h5> <h3>Anatomy and physiology</h3> <h2>Ants</h2>'; function push_values(&$k, $depth, $content) { $output = array(); $cdepth = $depth[$k]; while ($k < count($depth)) { if ($depth[$k] == $cdepth) { $output[$content[$k]] = ''; $k++; } elseif ($depth[$k] > $cdepth) { $output[$content[$k-1]] = push_values($k, $depth, $content); } else { return $output; } } return $output; } preg_match_all('/<h(\d)>([^<]+)/', $html, $matches); $key = 0; print_r(push_values($key, $matches[1], $matches[2]));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Ili7U
function name:  (null)
number of ops:  18
compiled vars:  !0 = $html, !1 = $matches, !2 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%3Ch2%3ESpiders%3C%2Fh2%3E%0A%3Ch2%3EBeetles%3C%2Fh2%3E%0A%3Ch3%3EExternal+morphology%3C%2Fh3%3E%0A%3Ch4%3EHead%3C%2Fh4%3E%0A%3Ch4%3EThorax%3C%2Fh4%3E%0A%3Ch4%3ELegs%3C%2Fh4%3E%0A%3Ch5%3EFeet%3C%2Fh5%3E%0A%3Ch3%3EAnatomy+and+physiology%3C%2Fh3%3E%0A%3Ch2%3EAnts%3C%2Fh2%3E'
   32     1        INIT_FCALL                                               'preg_match_all'
          2        SEND_VAL                                                 '%2F%3Ch%28%5Cd%29%3E%28%5B%5E%3C%5D%2B%29%2F'
          3        SEND_VAR                                                 !0
          4        SEND_REF                                                 !1
          5        DO_ICALL                                                 
   33     6        ASSIGN                                                   !2, 0
   34     7        INIT_FCALL                                               'print_r'
          8        INIT_FCALL                                               'push_values'
          9        SEND_REF                                                 !2
         10        FETCH_DIM_R                                      ~6      !1, 1
         11        SEND_VAL                                                 ~6
         12        FETCH_DIM_R                                      ~7      !1, 2
         13        SEND_VAL                                                 ~7
         14        DO_FCALL                                      0  $8      
         15        SEND_VAR                                                 $8
         16        DO_ICALL                                                 
         17      > RETURN                                                   1

Function push_values:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
2 jumps found. (Code = 44) Position 1 = 32, Position 2 = 7
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 15
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 28
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Ili7U
function name:  push_values
number of ops:  34
compiled vars:  !0 = $k, !1 = $depth, !2 = $content, !3 = $output, !4 = $cdepth
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   15     3        ASSIGN                                                   !3, <array>
   16     4        FETCH_DIM_R                                      ~6      !1, !0
          5        ASSIGN                                                   !4, ~6
   17     6      > JMP                                                      ->29
   18     7    >   FETCH_DIM_R                                      ~8      !1, !0
          8        IS_EQUAL                                                 !4, ~8
          9      > JMPZ                                                     ~9, ->15
   19    10    >   FETCH_DIM_R                                      ~10     !2, !0
         11        ASSIGN_DIM                                               !3, ~10
         12        OP_DATA                                                  ''
   20    13        PRE_INC                                                  !0
   18    14      > JMP                                                      ->29
   22    15    >   FETCH_DIM_R                                      ~13     !1, !0
         16        IS_SMALLER                                               !4, ~13
         17      > JMPZ                                                     ~14, ->28
   23    18    >   SUB                                              ~15     !0, 1
         19        FETCH_DIM_R                                      ~16     !2, ~15
         20        INIT_FCALL_BY_NAME                                       'push_values'
         21        SEND_VAR_EX                                              !0
         22        SEND_VAR_EX                                              !1
         23        SEND_VAR_EX                                              !2
         24        DO_FCALL                                      0  $18     
         25        ASSIGN_DIM                                               !3, ~16
         26        OP_DATA                                                  $18
   22    27      > JMP                                                      ->29
   26    28    > > RETURN                                                   !3
   17    29    >   COUNT                                            ~19     !1
         30        IS_SMALLER                                               !0, ~19
         31      > JMPNZ                                                    ~20, ->7
   29    32    > > RETURN                                                   !3
   30    33*     > RETURN                                                   null

End of function push_values

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.45 ms | 1019 KiB | 16 Q