3v4l.org

run code in 300+ PHP versions simultaneously
<?php $xml=simplexml_load_string(<<<XML <element> <feed id=" 9 "> <title>test</title> <table>feeds</table> <link/> <feed_type>API</feed_type> <affiliate/> <mwst>ja</mwst> <tld>DE</tld> <query/> </feed> </element> XML ); function deleteNode($feed_id) { global $xml; $node=$xml->xpath('//feed[@id=" '.$feed_id.' "]'); $node=dom_import_simplexml($node[0]); $parent=$node->parentNode; $parent->removeChild($node); $xml=simplexml_import_dom($parent->ownerDocument); } echo $xml->asXML(); echo "\n"; deleteNode("9"); echo $xml->asXML();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/K0MkW
function name:  (null)
number of ops:  15
compiled vars:  !0 = $xml
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   INIT_FCALL                                               'simplexml_load_string'
    3     1        SEND_VAL                                                 '%3Celement%3E%0A++++%3Cfeed+id%3D%22+9+%22%3E%0A++++++++%3Ctitle%3Etest%3C%2Ftitle%3E%0A++++++++%3Ctable%3Efeeds%3C%2Ftable%3E%0A++++++++%3Clink%2F%3E%0A++++++++%3Cfeed_type%3EAPI%3C%2Ffeed_type%3E%0A++++++++%3Caffiliate%2F%3E%0A++++++++%3Cmwst%3Eja%3C%2Fmwst%3E%0A++++++++%3Ctld%3EDE%3C%2Ftld%3E%0A++++++++%3Cquery%2F%3E%0A++++%3C%2Ffeed%3E%0A%3C%2Felement%3E'
          2        DO_ICALL                                         $1      
    2     3        ASSIGN                                                   !0, $1
   26     4        INIT_METHOD_CALL                                         !0, 'asXML'
          5        DO_FCALL                                      0  $3      
          6        ECHO                                                     $3
   27     7        ECHO                                                     '%0A'
   28     8        INIT_FCALL                                               'deletenode'
          9        SEND_VAL                                                 '9'
         10        DO_FCALL                                      0          
   29    11        INIT_METHOD_CALL                                         !0, 'asXML'
         12        DO_FCALL                                      0  $5      
         13        ECHO                                                     $5
         14      > RETURN                                                   1

Function deletenode:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/K0MkW
function name:  deleteNode
number of ops:  24
compiled vars:  !0 = $feed_id, !1 = $xml, !2 = $node, !3 = $parent
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
   19     1        BIND_GLOBAL                                              !1, 'xml'
   20     2        INIT_METHOD_CALL                                         !1, 'xpath'
          3        CONCAT                                           ~4      '%2F%2Ffeed%5B%40id%3D%22+', !0
          4        CONCAT                                           ~5      ~4, '+%22%5D'
          5        SEND_VAL_EX                                              ~5
          6        DO_FCALL                                      0  $6      
          7        ASSIGN                                                   !2, $6
   21     8        INIT_FCALL                                               'dom_import_simplexml'
          9        FETCH_DIM_R                                      ~8      !2, 0
         10        SEND_VAL                                                 ~8
         11        DO_ICALL                                         $9      
         12        ASSIGN                                                   !2, $9
   22    13        FETCH_OBJ_R                                      ~11     !2, 'parentNode'
         14        ASSIGN                                                   !3, ~11
   23    15        INIT_METHOD_CALL                                         !3, 'removeChild'
         16        SEND_VAR_EX                                              !2
         17        DO_FCALL                                      0          
   24    18        INIT_FCALL                                               'simplexml_import_dom'
         19        FETCH_OBJ_R                                      ~14     !3, 'ownerDocument'
         20        SEND_VAL                                                 ~14
         21        DO_ICALL                                         $15     
         22        ASSIGN                                                   !1, $15
   25    23      > RETURN                                                   null

End of function deletenode

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
167.03 ms | 1403 KiB | 20 Q