3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = '<xml version="1.0" encoding="utf-8"> <METADATA> <DATA> <FIELD_1>001</FIELD_1> <FIELD_2>ENTRY_2</FIELD_2> <FIELD_3>ENTRY_3</FIELD_3> <FIELD_4>ENTRY_4</FIELD_4> <FIELD_5>ENTRY_5</FIELD_5> <FIELD_6>000003</FIELD_6> <FIELD_7>ENTRY_7</FIELD_7> <FIELD_8>ENTRY_8</FIELD_8> <FIELD_9>ENTRY_9</FIELD_9> <FIELD_10>ENTRY_10</FIELD_10> <FIELD_11>ENTRY_11</FIELD_11> <FIELD_12>ENTRY_12</FIELD_12> <FIELD_13>ENTRY_13</FIELD_13> </DATA> </METADATA> </xml>'; $xml = simplexml_load_string($string); foreach ($xml->METADATA->DATA as $item) { foreach ($item->children() as $child) { $cols[] = $child->getName(); $params[] = $child->nodeValue; } if(!empty($params)){ $columns = implode(',', $cols); $placeholders = rtrim(str_repeat('?, ', count($params)), ', '); $sql = 'INSERT INTO dwh_xml ( ' . $columns . ') VALUES(' . $placeholders . ')'; echo $sql; unset($params, $cols); } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 49
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 49
Branch analysis from position: 9
2 jumps found. (Code = 77) Position 1 = 12, Position 2 = 21
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 21
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 48
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 48
Branch analysis from position: 21
Branch analysis from position: 49
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 49
filename:       /in/nhJi7
function name:  (null)
number of ops:  51
compiled vars:  !0 = $string, !1 = $xml, !2 = $item, !3 = $child, !4 = $cols, !5 = $params, !6 = $columns, !7 = $placeholders, !8 = $sql
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '%3Cxml+version%3D%221.0%22+encoding%3D%22utf-8%22%3E%0A++++%3CMETADATA%3E%0A++++++++%3CDATA%3E%0A++++++++++++%3CFIELD_1%3E001%3C%2FFIELD_1%3E%0A++++++++++++%3CFIELD_2%3EENTRY_2%3C%2FFIELD_2%3E%0A++++++++++++%3CFIELD_3%3EENTRY_3%3C%2FFIELD_3%3E%0A++++++++++++%3CFIELD_4%3EENTRY_4%3C%2FFIELD_4%3E%0A++++++++++++%3CFIELD_5%3EENTRY_5%3C%2FFIELD_5%3E%0A++++++++++++%3CFIELD_6%3E000003%3C%2FFIELD_6%3E%0A++++++++++++%3CFIELD_7%3EENTRY_7%3C%2FFIELD_7%3E%0A++++++++++++%3CFIELD_8%3EENTRY_8%3C%2FFIELD_8%3E%0A++++++++++++%3CFIELD_9%3EENTRY_9%3C%2FFIELD_9%3E%0A++++++++++++%3CFIELD_10%3EENTRY_10%3C%2FFIELD_10%3E%0A++++++++++++%3CFIELD_11%3EENTRY_11%3C%2FFIELD_11%3E%0A++++++++++++%3CFIELD_12%3EENTRY_12%3C%2FFIELD_12%3E%0A++++++++++++%3CFIELD_13%3EENTRY_13%3C%2FFIELD_13%3E%0A++++++++%3C%2FDATA%3E%0A++++%3C%2FMETADATA%3E%0A%3C%2Fxml%3E'
   21     1        INIT_FCALL                                               'simplexml_load_string'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $10     
          4        ASSIGN                                                   !1, $10
   22     5        FETCH_OBJ_R                                      ~12     !1, 'METADATA'
          6        FETCH_OBJ_R                                      ~13     ~12, 'DATA'
          7      > FE_RESET_R                                       $14     ~13, ->49
          8    > > FE_FETCH_R                                               $14, !2, ->49
   23     9    >   INIT_METHOD_CALL                                         !2, 'children'
         10        DO_FCALL                                      0  $15     
         11      > FE_RESET_R                                       $16     $15, ->21
         12    > > FE_FETCH_R                                               $16, !3, ->21
   24    13    >   INIT_METHOD_CALL                                         !3, 'getName'
         14        DO_FCALL                                      0  $18     
         15        ASSIGN_DIM                                               !4
         16        OP_DATA                                                  $18
   25    17        FETCH_OBJ_R                                      ~20     !3, 'nodeValue'
         18        ASSIGN_DIM                                               !5
         19        OP_DATA                                                  ~20
   23    20      > JMP                                                      ->12
         21    >   FE_FREE                                                  $16
   27    22        ISSET_ISEMPTY_CV                                 ~21     !5
         23        BOOL_NOT                                         ~22     ~21
         24      > JMPZ                                                     ~22, ->48
   28    25    >   INIT_FCALL                                               'implode'
         26        SEND_VAL                                                 '%2C'
         27        SEND_VAR                                                 !4
         28        DO_ICALL                                         $23     
         29        ASSIGN                                                   !6, $23
   29    30        INIT_FCALL                                               'rtrim'
         31        INIT_FCALL                                               'str_repeat'
         32        SEND_VAL                                                 '%3F%2C+'
         33        COUNT                                            ~25     !5
         34        SEND_VAL                                                 ~25
         35        DO_ICALL                                         $26     
         36        SEND_VAR                                                 $26
         37        SEND_VAL                                                 '%2C+'
         38        DO_ICALL                                         $27     
         39        ASSIGN                                                   !7, $27
   30    40        CONCAT                                           ~29     'INSERT+INTO+dwh_xml+%28+', !6
         41        CONCAT                                           ~30     ~29, '%29+VALUES%28'
         42        CONCAT                                           ~31     ~30, !7
         43        CONCAT                                           ~32     ~31, '%29'
         44        ASSIGN                                                   !8, ~32
   31    45        ECHO                                                     !8
   32    46        UNSET_CV                                                 !5
         47        UNSET_CV                                                 !4
   22    48    > > JMP                                                      ->8
         49    >   FE_FREE                                                  $14
   34    50      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.94 ms | 1010 KiB | 17 Q