3v4l.org

run code in 300+ PHP versions simultaneously
<?php $attributes = array(); $htmlcontent = '<img alt="" src="{assets_2100:{filedir_12}HappyDog.jpg}" style="height:400px; width:100px">'; preg_replace_callback('/src=(\'|")(.*?)\1/', function($matches) use ($attributes) { global $attributes; $terms = preg_split('/\{|\}/', $matches[2], -1, PREG_SPLIT_NO_EMPTY); foreach($terms as $key => $term) { if($key != (count($terms) - 1)) { $params = explode('_', $term); $attributes['data-' . rtrim($params[0], ':')] = $params[1]; } else { $attributes['src'] = 'uploads/' . $term; } } }, $htmlcontent); print_r($attributes);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2KMsU
function name:  (null)
number of ops:  13
compiled vars:  !0 = $attributes, !1 = $htmlcontent
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    3     1        ASSIGN                                                   !1, '%3Cimg+alt%3D%22%22+src%3D%22%7Bassets_2100%3A%7Bfiledir_12%7DHappyDog.jpg%7D%22+style%3D%22height%3A400px%3B+width%3A100px%22%3E'
    4     2        INIT_FCALL                                               'preg_replace_callback'
          3        SEND_VAL                                                 '%2Fsrc%3D%28%27%7C%22%29%28.%2A%3F%29%5C1%2F'
          4        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F2KMsU%3A4%240'
          5        BIND_LEXICAL                                             ~4, !0
   15     6        SEND_VAL                                                 ~4
          7        SEND_VAR                                                 !1
          8        DO_ICALL                                                 
   16     9        INIT_FCALL                                               'print_r'
         10        SEND_VAR                                                 !0
         11        DO_ICALL                                                 
         12      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2F2KMsU%3A4%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 12, Position 2 = 37
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 37
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 33
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 36
Branch analysis from position: 36
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 37
filename:       /in/2KMsU
function name:  {closure}
number of ops:  39
compiled vars:  !0 = $matches, !1 = $attributes, !2 = $terms, !3 = $term, !4 = $key, !5 = $params
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
    5     2        BIND_GLOBAL                                              !1, 'attributes'
    6     3        INIT_FCALL                                               'preg_split'
          4        SEND_VAL                                                 '%2F%5C%7B%7C%5C%7D%2F'
          5        FETCH_DIM_R                                      ~6      !0, 2
          6        SEND_VAL                                                 ~6
          7        SEND_VAL                                                 -1
          8        SEND_VAL                                                 1
          9        DO_ICALL                                         $7      
         10        ASSIGN                                                   !2, $7
    7    11      > FE_RESET_R                                       $9      !2, ->37
         12    > > FE_FETCH_R                                       ~10     $9, !3, ->37
         13    >   ASSIGN                                                   !4, ~10
    8    14        COUNT                                            ~12     !2
         15        SUB                                              ~13     ~12, 1
         16        IS_NOT_EQUAL                                             !4, ~13
         17      > JMPZ                                                     ~14, ->33
    9    18    >   INIT_FCALL                                               'explode'
         19        SEND_VAL                                                 '_'
         20        SEND_VAR                                                 !3
         21        DO_ICALL                                         $15     
         22        ASSIGN                                                   !5, $15
   10    23        INIT_FCALL                                               'rtrim'
         24        FETCH_DIM_R                                      ~17     !5, 0
         25        SEND_VAL                                                 ~17
         26        SEND_VAL                                                 '%3A'
         27        DO_ICALL                                         $18     
         28        CONCAT                                           ~19     'data-', $18
         29        FETCH_DIM_R                                      ~21     !5, 1
         30        ASSIGN_DIM                                               !1, ~19
         31        OP_DATA                                                  ~21
         32      > JMP                                                      ->36
   12    33    >   CONCAT                                           ~23     'uploads%2F', !3
         34        ASSIGN_DIM                                               !1, 'src'
         35        OP_DATA                                                  ~23
    7    36    > > JMP                                                      ->12
         37    >   FE_FREE                                                  $9
   15    38      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F2KMsU%3A4%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.29 ms | 1405 KiB | 23 Q