3v4l.org

run code in 300+ PHP versions simultaneously
<?php $cssClasses = [ 'container' => 'width: 100%;padding-right: 15px;padding-left: 15px;margin-right: auto;margin-left: auto;', 'card' => 'position: relative;display: -ms-flexbox;display: flex;-ms-flex-direction: column;flex-direction: column;min-width: 0;word-wrap: break-word;background-color: #fff;background-clip: border-box;border: 1px solid rgba(0, 0, 0, 0.125);border-radius: 0.25rem;' ]; $html = <<<'EOD' <div class="container"> 01 <div class="card"> 02 </div> </div> EOD; $dom = new DOMDocument; $dom->loadHTML($html); $divNL = $dom->getElementsByTagName('div'); for ($i = $divNL->length - 1; $i >= 0; $i--) { $node = $divNL->item($i); $table = $dom->createElement('table'); $tr = $dom->createElement('tr'); $td = $dom->createElement('td'); $table->appendChild($tr); $tr->appendChild($td); foreach ($node->attributes as $attr) { $td->appendChild($attr); } $styles = array_reduce( preg_split('~\s+~u', $td->getAttribute('class')), function($c, $i) use ($cssClasses) { return isset($cssClasses[$i]) ? $cssClasses[$i] . $c : $c; }, $td->getAttribute('style') ); if ( !empty($styles) ) $td->setAttribute('style', $styles); foreach ($node->childNodes as $childNode) { $td->appendChild($childNode->cloneNode(true)); } $node->parentNode->replaceChild($table, $node); } $result = ''; foreach ($dom->getElementsByTagName('body')->item(0)->childNodes as $childNode) { $result .= $dom->saveHTML($childNode); } echo $result;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 89
Branch analysis from position: 89
2 jumps found. (Code = 44) Position 1 = 91, Position 2 = 16
Branch analysis from position: 91
2 jumps found. (Code = 77) Position 1 = 100, Position 2 = 106
Branch analysis from position: 100
2 jumps found. (Code = 78) Position 1 = 101, Position 2 = 106
Branch analysis from position: 101
1 jumps found. (Code = 42) Position 1 = 100
Branch analysis from position: 100
Branch analysis from position: 106
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 106
Branch analysis from position: 16
2 jumps found. (Code = 77) Position 1 = 40, Position 2 = 45
Branch analysis from position: 40
2 jumps found. (Code = 78) Position 1 = 41, Position 2 = 45
Branch analysis from position: 41
1 jumps found. (Code = 42) Position 1 = 40
Branch analysis from position: 40
Branch analysis from position: 45
2 jumps found. (Code = 43) Position 1 = 67, Position 2 = 71
Branch analysis from position: 67
2 jumps found. (Code = 77) Position 1 = 73, Position 2 = 81
Branch analysis from position: 73
2 jumps found. (Code = 78) Position 1 = 74, Position 2 = 81
Branch analysis from position: 74
1 jumps found. (Code = 42) Position 1 = 73
Branch analysis from position: 73
Branch analysis from position: 81
2 jumps found. (Code = 44) Position 1 = 91, Position 2 = 16
Branch analysis from position: 91
Branch analysis from position: 16
Branch analysis from position: 81
Branch analysis from position: 71
Branch analysis from position: 45
filename:       /in/sAWll
function name:  (null)
number of ops:  109
compiled vars:  !0 = $cssClasses, !1 = $html, !2 = $dom, !3 = $divNL, !4 = $i, !5 = $node, !6 = $table, !7 = $tr, !8 = $td, !9 = $attr, !10 = $styles, !11 = $childNode, !12 = $result
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   3     0  E >   QM_ASSIGN                                                !0
   8     1        QM_ASSIGN                                                !1
  16     2        NEW                                              $15     :211
         3        DO_FCALL                                      0          
         4        QM_ASSIGN                                                !2
  17     5        INIT_METHOD_CALL                                         !2, 'loadHTML'
         6        SEND_VAR_EX                                              !1
         7        DO_FCALL                                      0          
  19     8        INIT_METHOD_CALL                                         !2, 'getElementsByTagName'
         9        SEND_VAL_EX                                              'div'
        10        DO_FCALL                                      0  $19     
        11        QM_ASSIGN                                                !3
  21    12        FETCH_OBJ_R                                      ~21     !3, 'length'
        13        SUB                                              ~22     ~21, 1
        14        QM_ASSIGN                                                !4
        15      > JMP                                                      ->89
  22    16    >   INIT_METHOD_CALL                                         !3, 'item'
        17        SEND_VAR_EX                                              !4
        18        DO_FCALL                                      0  $24     
        19        QM_ASSIGN                                                !5
  24    20        INIT_METHOD_CALL                                         !2, 'createElement'
        21        SEND_VAL_EX                                              'table'
        22        DO_FCALL                                      0  $26     
        23        QM_ASSIGN                                                !6
  25    24        INIT_METHOD_CALL                                         !2, 'createElement'
        25        SEND_VAL_EX                                              'tr'
        26        DO_FCALL                                      0  $28     
        27        QM_ASSIGN                                                !7
  26    28        INIT_METHOD_CALL                                         !2, 'createElement'
        29        SEND_VAL_EX                                              'td'
        30        DO_FCALL                                      0  $30     
        31        QM_ASSIGN                                                !8
  27    32        INIT_METHOD_CALL                                         !6, 'appendChild'
        33        SEND_VAR_EX                                              !7
        34        DO_FCALL                                      0          
  28    35        INIT_METHOD_CALL                                         !7, 'appendChild'
        36        SEND_VAR_EX                                              !8
        37        DO_FCALL                                      0          
  30    38        FETCH_OBJ_R                                      ~34     !5, 'attributes'
        39      > FE_RESET_R                                       $35     ~34, ->45
        40    > > FE_FETCH_R                                               $35, !9, ->45
  31    41    >   INIT_METHOD_CALL                                         !8, 'appendChild'
        42        SEND_VAR_EX                                              !9
        43        DO_FCALL                                      0          
  30    44      > JMP                                                      ->40
        45    >   FE_FREE                                                  $35
  34    46        INIT_FCALL                                               'array_reduce'
  35    47        INIT_FCALL                                               'preg_split'
        48        SEND_VAL                                                 '%7E%5Cs%2B%7Eu'
        49        INIT_METHOD_CALL                                         !8, 'getAttribute'
        50        SEND_VAL_EX                                              'class'
        51        DO_FCALL                                      0  $37     
        52        SEND_VAR                                                 $37
        53        DO_ICALL                                         $38     
        54        SEND_VAR                                                 $38
  36    55        RAISE_ABSTRACT_ERROR                             ~39     '%00%7Bclosure%7D%2Fin%2FsAWll0x7fbbd007a48b'
        56        BIND_LEXICAL                                             ~39, !0
  38    57        SEND_VAL                                                 ~39
  39    58        INIT_METHOD_CALL                                         !8, 'getAttribute'
        59        SEND_VAL_EX                                              'style'
        60        DO_FCALL                                      0  $40     
        61        SEND_VAR                                                 $40
        62        DO_ICALL                                         $41     
        63        QM_ASSIGN                                                !10
  42    64        ADD_TRAIT                                        ~43     !10
        65        BOOL_XOR                                         ~44     ~43
        66      > JMPZ                                                     ~44, ->71
  43    67    >   INIT_METHOD_CALL                                         !8, 'setAttribute'
        68        SEND_VAL_EX                                              'style'
        69        SEND_VAR_EX                                              !10
        70        DO_FCALL                                      0          
  46    71    >   FETCH_OBJ_R                                      ~46     !5, 'childNodes'
        72      > FE_RESET_R                                       $47     ~46, ->81
        73    > > FE_FETCH_R                                               $47, !11, ->81
  47    74    >   INIT_METHOD_CALL                                         !8, 'appendChild'
        75        INIT_METHOD_CALL                                         !11, 'cloneNode'
        76        SEND_VAL_EX                                              <true>
        77        DO_FCALL                                      0  $48     
        78        SEND_VAR_NO_REF_EX                                       $48
        79        DO_FCALL                                      0          
  46    80      > JMP                                                      ->73
        81    >   FE_FREE                                                  $47
  50    82        FETCH_OBJ_R                                      ~50     !5, 'parentNode'
        83        INIT_METHOD_CALL                                         ~50, 'replaceChild'
        84        SEND_VAR_EX                                              !6
        85        SEND_VAR_EX                                              !5
        86        DO_FCALL                                      0          
  21    87        POST_DEC                                         ~52     !4
        88        FREE                                                     ~52
        89    >   CAST                                          0  ~53     0, !4
        90      > JMPNZ                                                    ~53, ->16
  54    91    >   QM_ASSIGN                                                !12
  56    92        INIT_METHOD_CALL                                         !2, 'getElementsByTagName'
        93        SEND_VAL_EX                                              'body'
        94        DO_FCALL                                      0  $55     
        95        INIT_METHOD_CALL                                         $55, 'item'
        96        SEND_VAL_EX                                              0
        97        DO_FCALL                                      0  $56     
        98        FETCH_OBJ_R                                      ~57     $56, 'childNodes'
        99      > FE_RESET_R                                       $58     ~57, ->106
       100    > > FE_FETCH_R                                               $58, !11, ->106
  57   101    >   INIT_METHOD_CALL                                         !2, 'saveHTML'
       102        SEND_VAR_EX                                              !11
       103        DO_FCALL                                      0  $59     
       104        ASSIGN_DIV                                    8          !12, $59
  56   105      > JMP                                                      ->100
       106    >   FE_FREE                                                  $58
  60   107        ASSIGN_OBJ                                               !12
  61   108      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FsAWll0x7fbbd007a48b:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 9
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/sAWll
function name:  {closure}
number of ops:  12
compiled vars:  !0 = $c, !1 = $i, !2 = $cssClasses
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  36     0  E >   RECV                                             !0      
         1        RECV                                             !1      
         2        BIND_STATIC                                              !2
  37     3        ISSET_ISEMPTY_DIM_OBJ                         0  ~3      !2, !1
         4      > JMPZ                                                     ~3, ->9
         5    >   FETCH_DIM_R                                      ~4      !2, !1
         6        CONCAT                                           ~5      ~4, !0
         7        ASSIGN_BW_OR                                  0  ~6      ~5
         8      > JMP                                                      ->10
         9    >   ASSIGN_BW_OR                                  0  ~6      !0
        10    > > RETURN                                                   ~6
  38    11*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FsAWll0x7fbbd007a48b

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
16.17 ms | 424 KiB | 7 Q