3v4l.org

run code in 300+ PHP versions simultaneously
<?php $_POST['content'] = '<path d="m34.511 143.4v3.0302l54.101-0.63086v-2.078z" points="34.510773,146.42924 88.611514,145.79838 88.611514,143.72037 34.510773,143.39908" fill="#353564"/> <path d="m34.511 146.43 78.119 2.1017 56.193-2.4552-80.211-0.27738z" points="112.6299,148.53093 168.82266,146.07576 88.611514,145.79838 34.510773,146.42924" fill="#afafde"/>'; //first make the post content valid XML $xml = '<xmp>' . $_POST['content'] . '</xmp>'; //load it as a DOMDOcument to parse the desired tags of path $doc = new DOMDocument(); $doc->loadXML($xml); $array = []; //find all of the <path/> tags foreach($doc->getElementsByTagName('path') as $node) { $attributes = []; //convert the attributes into an associative array by attribute name foreach($node->attributes as $attribute) { $attributes[$attribute->name] = $attribute->value; } //store the tag and attributes into array $array[] = (object) [ $node->tagName => $attributes ]; } //convert the PHP array to a JSON string of an array of objects $json = json_encode($array, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_NUMERIC_CHECK | JSON_PRETTY_PRINT); print_r($json);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 19, Position 2 = 36
Branch analysis from position: 19
2 jumps found. (Code = 78) Position 1 = 20, Position 2 = 36
Branch analysis from position: 20
2 jumps found. (Code = 77) Position 1 = 23, Position 2 = 29
Branch analysis from position: 23
2 jumps found. (Code = 78) Position 1 = 24, Position 2 = 29
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
Branch analysis from position: 29
Branch analysis from position: 36
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 36
filename:       /in/hOepd
function name:  (null)
number of ops:  46
compiled vars:  !0 = $xml, !1 = $doc, !2 = $array, !3 = $node, !4 = $attributes, !5 = $attribute, !6 = $json
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   FETCH_W                      global              $7      '_POST'
          1        ASSIGN_DIM                                               $7, 'content'
          2        OP_DATA                                                  '%3Cpath+d%3D%22m34.511+143.4v3.0302l54.101-0.63086v-2.078z%22+points%3D%2234.510773%2C146.42924+88.611514%2C145.79838+88.611514%2C143.72037+34.510773%2C143.39908%22+fill%3D%22%23353564%22%2F%3E%0A%3Cpath+d%3D%22m34.511+146.43+78.119+2.1017+56.193-2.4552-80.211-0.27738z%22+points%3D%22112.6299%2C148.53093+168.82266%2C146.07576+88.611514%2C145.79838+34.510773%2C146.42924%22+fill%3D%22%23afafde%22%2F%3E'
    7     3        FETCH_R                      global              ~9      '_POST'
          4        FETCH_DIM_R                                      ~10     ~9, 'content'
          5        CONCAT                                           ~11     '%3Cxmp%3E', ~10
          6        CONCAT                                           ~12     ~11, '%3C%2Fxmp%3E'
          7        ASSIGN                                                   !0, ~12
   10     8        NEW                                              $14     'DOMDocument'
          9        DO_FCALL                                      0          
         10        ASSIGN                                                   !1, $14
   11    11        INIT_METHOD_CALL                                         !1, 'loadXML'
         12        SEND_VAR_EX                                              !0
         13        DO_FCALL                                      0          
   12    14        ASSIGN                                                   !2, <array>
   14    15        INIT_METHOD_CALL                                         !1, 'getElementsByTagName'
         16        SEND_VAL_EX                                              'path'
         17        DO_FCALL                                      0  $19     
         18      > FE_RESET_R                                       $20     $19, ->36
         19    > > FE_FETCH_R                                               $20, !3, ->36
   16    20    >   ASSIGN                                                   !4, <array>
   18    21        FETCH_OBJ_R                                      ~22     !3, 'attributes'
         22      > FE_RESET_R                                       $23     ~22, ->29
         23    > > FE_FETCH_R                                               $23, !5, ->29
   19    24    >   FETCH_OBJ_R                                      ~24     !5, 'name'
         25        FETCH_OBJ_R                                      ~26     !5, 'value'
         26        ASSIGN_DIM                                               !4, ~24
         27        OP_DATA                                                  ~26
   18    28      > JMP                                                      ->23
         29    >   FE_FREE                                                  $23
   23    30        FETCH_OBJ_R                                      ~28     !3, 'tagName'
         31        INIT_ARRAY                                       ~29     !4, ~28
         32        CAST                                          8  ~30     ~29
   22    33        ASSIGN_DIM                                               !2
   23    34        OP_DATA                                                  ~30
   14    35      > JMP                                                      ->19
         36    >   FE_FREE                                                  $20
   28    37        INIT_FCALL                                               'json_encode'
         38        SEND_VAR                                                 !2
         39        SEND_VAL                                                 480
         40        DO_ICALL                                         $31     
         41        ASSIGN                                                   !6, $31
   29    42        INIT_FCALL                                               'print_r'
         43        SEND_VAR                                                 !6
         44        DO_ICALL                                                 
         45      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
121.53 ms | 1006 KiB | 15 Q