3v4l.org

run code in 300+ PHP versions simultaneously
<?php function writeXML( $xml, $data ) { foreach( $data as $key => $value ) { if ( preg_match('/^(.*) (.*)=(.*)$/', $key, $matches) != false ) { $xml->startElement( $matches[1] ); $xml->writeAttribute( $matches[2], $matches[3]); if( is_array( $value )) { writeXML( $xml, $value ); $xml->endElement( ); continue; } $xml->text( $value ); $xml->endElement( ); } else { if( is_array( $value )) { $xml->startElement( $key ); writeXML( $xml, $value ); $xml->endElement( ); continue; } echo $key. "\n"; $xml->writeElement( $key, $value ); } } } $name = 'item'; $xml = new XmlWriter(); $xml->openMemory(); $xml->startDocument( '1.0', 'utf-8' ); $xml->startElement( $name ); $data = array( "episodeTitle" => 'test', "episodeDescription" => 'test', "pubDate" => 'test', "imdbid" => 'test', "MediaType" => "TV", "seasonNumber" => 1, "episodeNumber" => 1, "episodeImage" => array ( "url" => 'test', ), "duration" => 'test', "episodeKeywords" => "", "episodePopularity scale=" => 5, "VideoType" => "Episode", "country" => "United States", "language" => "en-us", "geoRestrictions" => 'test', //"dateAvailable" => $start_date, //"expDate" =>$end_date, "category" => 'test', "sourceID" => 'test', "streamType" => "SD", //TODO: multiple formats? "iOSAllowed" => 1, "subscription" => "yes", "price" => 0.00, "videoURL" => 'test', "showtitle" => 'test', "link" => "http://www.flixfling.com/movies/", "showdescription" => 'test', "showLogo" => array ( "url" => 'test', ), "showsourceID" => 'test', "showPubDate" => 'test', "showImdbid>" => 'test', "showCategory" => 'test', "showKeywords" => "", ); writeXML( $xml, $data);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/UnUgG
function name:  (null)
number of ops:  19
compiled vars:  !0 = $name, !1 = $xml, !2 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   ASSIGN                                                   !0, 'item'
   29     1        NEW                                              $4      'XmlWriter'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $4
   30     4        INIT_METHOD_CALL                                         !1, 'openMemory'
          5        DO_FCALL                                      0          
   31     6        INIT_METHOD_CALL                                         !1, 'startDocument'
          7        SEND_VAL_EX                                              '1.0'
          8        SEND_VAL_EX                                              'utf-8'
          9        DO_FCALL                                      0          
   32    10        INIT_METHOD_CALL                                         !1, 'startElement'
         11        SEND_VAR_EX                                              !0
         12        DO_FCALL                                      0          
   33    13        ASSIGN                                                   !2, <array>
   72    14        INIT_FCALL                                               'writexml'
         15        SEND_VAR                                                 !1
         16        SEND_VAR                                                 !2
         17        DO_FCALL                                      0          
         18      > RETURN                                                   1

Function writexml:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 59
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 59
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 40
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 34
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 34
1 jumps found. (Code = 42) Position 1 = 58
Branch analysis from position: 58
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 40
2 jumps found. (Code = 43) Position 1 = 42, Position 2 = 52
Branch analysis from position: 42
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 52
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 59
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 59
filename:       /in/UnUgG
function name:  writeXML
number of ops:  61
compiled vars:  !0 = $xml, !1 = $data, !2 = $value, !3 = $key, !4 = $matches
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    3     2      > FE_RESET_R                                       $5      !1, ->59
          3    > > FE_FETCH_R                                       ~6      $5, !2, ->59
          4    >   ASSIGN                                                   !3, ~6
    4     5        INIT_FCALL                                               'preg_match'
          6        SEND_VAL                                                 '%2F%5E%28.%2A%29+%28.%2A%29%3D%28.%2A%29%24%2F'
          7        SEND_VAR                                                 !3
          8        SEND_REF                                                 !4
          9        DO_ICALL                                         $8      
         10        BOOL                                             ~9      $8
         11      > JMPZ                                                     ~9, ->40
    5    12    >   INIT_METHOD_CALL                                         !0, 'startElement'
         13        CHECK_FUNC_ARG                                           
         14        FETCH_DIM_FUNC_ARG                               $10     !4, 1
         15        SEND_FUNC_ARG                                            $10
         16        DO_FCALL                                      0          
    6    17        INIT_METHOD_CALL                                         !0, 'writeAttribute'
         18        CHECK_FUNC_ARG                                           
         19        FETCH_DIM_FUNC_ARG                               $12     !4, 2
         20        SEND_FUNC_ARG                                            $12
         21        CHECK_FUNC_ARG                                           
         22        FETCH_DIM_FUNC_ARG                               $13     !4, 3
         23        SEND_FUNC_ARG                                            $13
         24        DO_FCALL                                      0          
    7    25        TYPE_CHECK                                  128          !2
         26      > JMPZ                                                     ~15, ->34
    8    27    >   INIT_FCALL_BY_NAME                                       'writeXML'
         28        SEND_VAR_EX                                              !0
         29        SEND_VAR_EX                                              !2
         30        DO_FCALL                                      0          
    9    31        INIT_METHOD_CALL                                         !0, 'endElement'
         32        DO_FCALL                                      0          
   10    33      > JMP                                                      ->3
   12    34    >   INIT_METHOD_CALL                                         !0, 'text'
         35        SEND_VAR_EX                                              !2
         36        DO_FCALL                                      0          
   13    37        INIT_METHOD_CALL                                         !0, 'endElement'
         38        DO_FCALL                                      0          
    4    39      > JMP                                                      ->58
   16    40    >   TYPE_CHECK                                  128          !2
         41      > JMPZ                                                     ~20, ->52
   17    42    >   INIT_METHOD_CALL                                         !0, 'startElement'
         43        SEND_VAR_EX                                              !3
         44        DO_FCALL                                      0          
   18    45        INIT_FCALL_BY_NAME                                       'writeXML'
         46        SEND_VAR_EX                                              !0
         47        SEND_VAR_EX                                              !2
         48        DO_FCALL                                      0          
   19    49        INIT_METHOD_CALL                                         !0, 'endElement'
         50        DO_FCALL                                      0          
   20    51      > JMP                                                      ->3
   22    52    >   CONCAT                                           ~24     !3, '%0A'
         53        ECHO                                                     ~24
   23    54        INIT_METHOD_CALL                                         !0, 'writeElement'
         55        SEND_VAR_EX                                              !3
         56        SEND_VAR_EX                                              !2
         57        DO_FCALL                                      0          
    3    58    > > JMP                                                      ->3
         59    >   FE_FREE                                                  $5
   26    60      > RETURN                                                   null

End of function writexml

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.9 ms | 1021 KiB | 15 Q