3v4l.org

run code in 500+ PHP versions simultaneously
<?php $xml = '<rss version="2.0" xmlns:a10="http://www.w3.org/2005/Atom"> <channel> <title>mMin title</title> <description>Some description</description> <managingEditor>john.doe@example.com</managingEditor> <category>Some category</category> <item> <guid isPermaLink="false">1</guid> <link>https://example.com/1</link> <title>Some title 1</title> <a10:updated>2017-05-30T13:20:22+02:00</a10:updated> <a10:content type="text/xml"> <Location>San diego</Location> <PublishedOn>2016-10-21T11:21:07</PublishedOn> <Body>Lorem ipsum dolar</Body> <JobCountry>USA</JobCountry> </a10:content> </item> <item> <guid isPermaLink="false">1</guid> <link>https://example.com/2</link> <title>Some title 2</title> <a10:updated>2017-05-30T13:20:22+02:00</a10:updated> <a10:content type="text/xml"> <Location>Detroit</Location> <PublishedOn>2016-10-21T11:21:07</PublishedOn> <Body>Lorem ipsum dolar</Body> <JobCountry>USA</JobCountry> </a10:content> </item> <item> <guid isPermaLink="false">1</guid> <link>https://example.com/3</link> <title>Some title 3</title> <a10:updated>2017-05-30T13:20:22+02:00</a10:updated> <a10:content type="text/xml"> <Location>Los Angeles</Location> <PublishedOn>2016-10-21T11:21:07</PublishedOn> <Body>Lorem ipsum dolar</Body> <JobCountry>USA</JobCountry> </a10:content> </item> </channel> </rss>'; function domToArray($item, array $cols) { $array = []; foreach ($cols as $col) { $val = $item->getElementsByTagName($col)->item(0)->nodeValue; $array[$col] = $val; } return $array; } $dom = new DOMDocument(); $dom->loadXML($xml); $items = $dom->getElementsByTagName('item'); $array = array(); $fields = [ 'title', 'link', 'updated', 'Location', 'PublishedOn', 'Body', 'JobCountry', ]; foreach($items as $item) { $array[] = domToArray($item, $fields); } var_dump($array);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 14, Position 2 = 22
Branch analysis from position: 14
2 jumps found. (Code = 78) Position 1 = 15, Position 2 = 22
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
filename:       /in/W6HM3
function name:  (null)
number of ops:  27
compiled vars:  !0 = $xml, !1 = $dom, !2 = $items, !3 = $array, !4 = $fields, !5 = $item
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, '%3Crss+version%3D%222.0%22+xmlns%3Aa10%3D%22http%3A%2F%2Fwww.w3.org%2F2005%2FAtom%22%3E%0A++++%3Cchannel%3E%0A++++++++%3Ctitle%3EmMin+title%3C%2Ftitle%3E%0A++++++++%3Cdescription%3ESome+description%3C%2Fdescription%3E%0A++++++++%3CmanagingEditor%3Ejohn.doe%40example.com%3C%2FmanagingEditor%3E%0A++++++++%3Ccategory%3ESome+category%3C%2Fcategory%3E%0A++++++++%3Citem%3E%0A++++++++++++%3Cguid+isPermaLink%3D%22false%22%3E1%3C%2Fguid%3E%0A++++++++++++%3Clink%3Ehttps%3A%2F%2Fexample.com%2F1%3C%2Flink%3E%0A++++++++++++%3Ctitle%3ESome+title+1%3C%2Ftitle%3E%0A++++++++++++%3Ca10%3Aupdated%3E2017-05-30T13%3A20%3A22%2B02%3A00%3C%2Fa10%3Aupdated%3E%0A++++++++++++%3Ca10%3Acontent+type%3D%22text%2Fxml%22%3E%0A++++++++++++++++%3CLocation%3ESan+diego%3C%2FLocation%3E%0A++++++++++++++++%3CPublishedOn%3E2016-10-21T11%3A21%3A07%3C%2FPublishedOn%3E%0A++++++++++++++++%3CBody%3ELorem+ipsum+dolar%3C%2FBody%3E%0A++++++++++++++++%3CJobCountry%3EUSA%3C%2FJobCountry%3E%0A++++++++++++%3C%2Fa10%3Acontent%3E%0A++++++++%3C%2Fitem%3E%0A++++++++%3Citem%3E%0A++++++++++++%3Cguid+isPermaLink%3D%22false%22%3E1%3C%2Fguid%3E%0A++++++++++++%3Clink%3Ehttps%3A%2F%2Fexample.com%2F2%3C%2Flink%3E%0A++++++++++++%3Ctitle%3ESome+title+2%3C%2Ftitle%3E%0A++++++++++++%3Ca10%3Aupdated%3E2017-05-30T13%3A20%3A22%2B02%3A00%3C%2Fa10%3Aupdated%3E%0A++++++++++++%3Ca10%3Acontent+type%3D%22text%2Fxml%22%3E%0A++++++++++++++++%3CLocation%3EDetroit%3C%2FLocation%3E%0A++++++++++++++++%3CPublishedOn%3E2016-10-21T11%3A21%3A07%3C%2FPublishedOn%3E%0A++++++++++++++++%3CBody%3ELorem+ipsum+dolar%3C%2FBody%3E%0A++++++++++++++++%3CJobCountry%3EUSA%3C%2FJobCountry%3E%0A++++++++++++%3C%2Fa10%3Acontent%3E%0A++++++++%3C%2Fitem%3E%0A++++++++%3Citem%3E%0A++++++++++++%3Cguid+isPermaLink%3D%22false%22%3E1%3C%2Fguid%3E%0A++++++++++++%3Clink%3Ehttps%3A%2F%2Fexample.com%2F3%3C%2Flink%3E%0A++++++++++++%3Ctitle%3ESome+title+3%3C%2Ftitle%3E%0A++++++++++++%3Ca10%3Aupdated%3E2017-05-30T13%3A20%3A22%2B02%3A00%3C%2Fa10%3Aupdated%3E%0A++++++++++++%3Ca10%3Acontent+type%3D%22text%2Fxml%22%3E%0A++++++++++++++++%3CLocation%3ELos+Angeles%3C%2FLocation%3E%0A++++++++++++++++%3CPublishedOn%3E2016-10-21T11%3A21%3A07%3C%2FPublishedOn%3E%0A++++++++++++++++%3CBody%3ELorem+ipsum+dolar%3C%2FBody%3E%0A++++++++++++++++%3CJobCountry%3EUSA%3C%2FJobCountry%3E%0A++++++++++++%3C%2Fa10%3Acontent%3E%0A++++++++%3C%2Fitem%3E%0A++++%3C%2Fchannel%3E%0A%3C%2Frss%3E'
   58     1        NEW                                                  $7      'DOMDocument'
          2        DO_FCALL                                          0          
          3        ASSIGN                                                       !1, $7
   59     4        INIT_METHOD_CALL                                             !1, 'loadXML'
          5        SEND_VAR_EX                                                  !0
          6        DO_FCALL                                          0          
   61     7        INIT_METHOD_CALL                                             !1, 'getElementsByTagName'
          8        SEND_VAL_EX                                                  'item'
          9        DO_FCALL                                          0  $11     
         10        ASSIGN                                                       !2, $11
   62    11        ASSIGN                                                       !3, <array>
   64    12        ASSIGN                                                       !4, <array>
   74    13      > FE_RESET_R                                           $15     !2, ->22
         14    > > FE_FETCH_R                                                   $15, !5, ->22
   76    15    >   INIT_FCALL                                                   'domtoarray'
         16        SEND_VAR                                                     !5
         17        SEND_VAR                                                     !4
         18        DO_FCALL                                          0  $17     
         19        ASSIGN_DIM                                                   !3
         20        OP_DATA                                                      $17
   74    21      > JMP                                                          ->14
         22    >   FE_FREE                                                      $15
   79    23        INIT_FCALL                                                   'var_dump'
         24        SEND_VAR                                                     !3
         25        DO_ICALL                                                     
         26      > RETURN                                                       1

Function domtoarray:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 16
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 16
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
filename:       /in/W6HM3
function name:  domToArray
number of ops:  19
compiled vars:  !0 = $item, !1 = $cols, !2 = $array, !3 = $col, !4 = $val
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   48     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
   50     2        ASSIGN                                                       !2, <array>
   51     3      > FE_RESET_R                                           $6      !1, ->16
          4    > > FE_FETCH_R                                                   $6, !3, ->16
   52     5    >   INIT_METHOD_CALL                                             !0, 'getElementsByTagName'
          6        SEND_VAR_EX                                                  !3
          7        DO_FCALL                                          0  $7      
          8        INIT_METHOD_CALL                                             $7, 'item'
          9        SEND_VAL_EX                                                  0
         10        DO_FCALL                                          0  $8      
         11        FETCH_OBJ_R                                          ~9      $8, 'nodeValue'
         12        ASSIGN                                                       !4, ~9
   53    13        ASSIGN_DIM                                                   !2, !3
         14        OP_DATA                                                      !4
   51    15      > JMP                                                          ->4
         16    >   FE_FREE                                                      $6
   55    17      > RETURN                                                       !2
   56    18*     > RETURN                                                       null

End of function domtoarray

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
171.14 ms | 2418 KiB | 15 Q