3v4l.org

run code in 300+ PHP versions simultaneously
<? $filexml='data.xml'; preg_match("/([a-zA-Z0-9_-]+).([a-zA-Z0-9]+)/", $filexml, $extension); //$timestamp = date("Y-m-d_H:i:s"); $timestamp = time(); //$timestamp gets current time $myFile = data.$timestamp.".".$extension[2]; echo $myFile; file_put_contents($myFile, file_get_contents("input.txt")); $mycsvFile = "orderData.".$timestamp.".csv"; // timestamp to file name echo $mycsvFile; if (file_exists($myFile)) { $xml = simplexml_load_file($myFile); $f = fopen($mycsvFile, 'w'); // open and write to file createCsv($xml, $f); fclose($f); } function createCsv($xml,$f) { foreach ($xml->children() as $item) { $hasChild = (count($item->children()) > 0)?true:false; if( ! $hasChild) { $put_arr = array($item->getName(),$item); fputcsv($f, $put_arr ,',','"'); } else { createCsv($item, $f); } } } ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 31, Position 2 = 47
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 47
filename:       /in/ARBW5
function name:  (null)
number of ops:  48
compiled vars:  !0 = $filexml, !1 = $extension, !2 = $timestamp, !3 = $myFile, !4 = $mycsvFile, !5 = $xml, !6 = $f
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, 'data.xml'
    3     1        INIT_FCALL                                               'preg_match'
          2        SEND_VAL                                                 '%2F%28%5Ba-zA-Z0-9_-%5D%2B%29.%28%5Ba-zA-Z0-9%5D%2B%29%2F'
          3        SEND_VAR                                                 !0
          4        SEND_REF                                                 !1
          5        DO_ICALL                                                 
    5     6        INIT_FCALL                                               'time'
          7        DO_ICALL                                         $9      
          8        ASSIGN                                                   !2, $9
    6     9        FETCH_CONSTANT                                   ~11     'data'
         10        CONCAT                                           ~12     ~11, !2
         11        CONCAT                                           ~13     ~12, '.'
         12        FETCH_DIM_R                                      ~14     !1, 2
         13        CONCAT                                           ~15     ~13, ~14
         14        ASSIGN                                                   !3, ~15
    7    15        ECHO                                                     !3
    8    16        INIT_FCALL                                               'file_put_contents'
         17        SEND_VAR                                                 !3
         18        INIT_FCALL                                               'file_get_contents'
         19        SEND_VAL                                                 'input.txt'
         20        DO_ICALL                                         $17     
         21        SEND_VAR                                                 $17
         22        DO_ICALL                                                 
   10    23        CONCAT                                           ~19     'orderData.', !2
         24        CONCAT                                           ~20     ~19, '.csv'
         25        ASSIGN                                                   !4, ~20
   11    26        ECHO                                                     !4
   13    27        INIT_FCALL                                               'file_exists'
         28        SEND_VAR                                                 !3
         29        DO_ICALL                                         $22     
         30      > JMPZ                                                     $22, ->47
   15    31    >   INIT_FCALL                                               'simplexml_load_file'
         32        SEND_VAR                                                 !3
         33        DO_ICALL                                         $23     
         34        ASSIGN                                                   !5, $23
   16    35        INIT_FCALL                                               'fopen'
         36        SEND_VAR                                                 !4
         37        SEND_VAL                                                 'w'
         38        DO_ICALL                                         $25     
         39        ASSIGN                                                   !6, $25
   17    40        INIT_FCALL_BY_NAME                                       'createCsv'
         41        SEND_VAR_EX                                              !5
         42        SEND_VAR_EX                                              !6
         43        DO_FCALL                                      0          
   18    44        INIT_FCALL                                               'fclose'
         45        SEND_VAR                                                 !6
         46        DO_ICALL                                                 
   42    47    > > RETURN                                                   1

Function createcsv:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 34
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 34
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 13
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 29
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 29
Branch analysis from position: 17
Branch analysis from position: 29
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 34
filename:       /in/ARBW5
function name:  createCsv
number of ops:  36
compiled vars:  !0 = $xml, !1 = $f, !2 = $item, !3 = $hasChild, !4 = $put_arr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   24     2        INIT_METHOD_CALL                                         !0, 'children'
          3        DO_FCALL                                      0  $5      
          4      > FE_RESET_R                                       $6      $5, ->34
          5    > > FE_FETCH_R                                               $6, !2, ->34
   27     6    >   INIT_METHOD_CALL                                         !2, 'children'
          7        DO_FCALL                                      0  $7      
          8        COUNT                                            ~8      $7
          9        IS_SMALLER                                               0, ~8
         10      > JMPZ                                                     ~9, ->13
         11    >   QM_ASSIGN                                        ~10     <true>
         12      > JMP                                                      ->14
         13    >   QM_ASSIGN                                        ~10     <false>
         14    >   ASSIGN                                                   !3, ~10
   29    15        BOOL_NOT                                         ~12     !3
         16      > JMPZ                                                     ~12, ->29
   31    17    >   INIT_METHOD_CALL                                         !2, 'getName'
         18        DO_FCALL                                      0  $13     
         19        INIT_ARRAY                                       ~14     $13
         20        ADD_ARRAY_ELEMENT                                ~14     !2
         21        ASSIGN                                                   !4, ~14
   32    22        INIT_FCALL                                               'fputcsv'
         23        SEND_VAR                                                 !1
         24        SEND_VAR                                                 !4
         25        SEND_VAL                                                 '%2C'
         26        SEND_VAL                                                 '%22'
         27        DO_ICALL                                                 
   29    28      > JMP                                                      ->33
   37    29    >   INIT_FCALL_BY_NAME                                       'createCsv'
         30        SEND_VAR_EX                                              !2
         31        SEND_VAR_EX                                              !1
         32        DO_FCALL                                      0          
   24    33    > > JMP                                                      ->5
         34    >   FE_FREE                                                  $6
   41    35      > RETURN                                                   null

End of function createcsv

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
140.84 ms | 1018 KiB | 22 Q