3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = '<!--HEAD--><p class="listing-grp-title">Top Ranked Offers</p><!--HEAD--> <!--WRAPPERSTART--><div><table><!--WRAPPERSTART--> <tr class="{% if forloop.counter|divisibleby:2 %}even{% else %}odd{% endif %}"> <td class="rank">&#35; {{forloop.counter}}</td> <td class="logo"> <img src="{{ad.display_url}}" width="120" height="40" alt="Aig Sml"/> </td> <td> <p class="offer">{{ad.headline}}</p> {{ad.body|safe}} </td> <td> <img src="images/arrow.png" width="14" height="18" alt=""/> </td> <td class="end"> <a href="#"><img class="button" src="images/sml-btn.png" width="112" height="30" alt=""/></a> </td> </tr> <!--WRAPPEREND--></table></div><!--WRAPPEREND-->'; $sub= 'sub_0_'; echo _format_special_tags($html,$sub); function _format_special_tags($html,$sub) { //where sub is sub_1_ or similar $tags = array(); $outer= "{% if forloop.counter = ".$sub."range.0 %}"; $end_outer = "{% endif %}"; $header = _return_between('<!--HEAD-->',$html); $wrapper_start = _return_between('<!--WRAPPERSTART-->',$html); $wrapper_end = _return_between('<!--WRAPPEREND-->',$html); $html = $outer.(($header)?$header:'').(($wrapper_start)?$wrapper_start:'').$end_outer.$html.$outer.(($wrapper_end)?$wrapper_end:'').$end_outer; return $html; } function _return_between($tag,$subject) { $split = explode($tag,$subject,3); return (isset($split[1]))?$split[1]:false; } function _remove_between($tag,$subject) { echo preg_replace("/".$tag.".+?".$tag."/i", "", $subject); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8O166
function name:  (null)
number of ops:  8
compiled vars:  !0 = $html, !1 = $sub
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%3C%21--HEAD--%3E%3Cp+class%3D%22listing-grp-title%22%3ETop+Ranked+Offers%3C%2Fp%3E%3C%21--HEAD--%3E%0A%3C%21--WRAPPERSTART--%3E%3Cdiv%3E%3Ctable%3E%3C%21--WRAPPERSTART--%3E%0A%3Ctr+class%3D%22%7B%25+if+forloop.counter%7Cdivisibleby%3A2+%25%7Deven%7B%25+else+%25%7Dodd%7B%25+endif+%25%7D%22%3E%0A%09%3Ctd+class%3D%22rank%22%3E%26%2335%3B+%7B%7Bforloop.counter%7D%7D%3C%2Ftd%3E%0A%09%3Ctd+class%3D%22logo%22%3E%0A%09%09%3Cimg+src%3D%22%7B%7Bad.display_url%7D%7D%22+width%3D%22120%22+height%3D%2240%22+alt%3D%22Aig+Sml%22%2F%3E%0A%09%3C%2Ftd%3E%0A%09%3Ctd%3E%0A%09%09%3Cp+class%3D%22offer%22%3E%7B%7Bad.headline%7D%7D%3C%2Fp%3E%0A%09%09%7B%7Bad.body%7Csafe%7D%7D%0A%09%3C%2Ftd%3E%0A%09%3Ctd%3E%0A%09%09%3Cimg+src%3D%22images%2Farrow.png%22+width%3D%2214%22+height%3D%2218%22+alt%3D%22%22%2F%3E%0A%09%3C%2Ftd%3E%0A%09%3Ctd+class%3D%22end%22%3E%0A%09%09%3Ca+href%3D%22%23%22%3E%3Cimg++class%3D%22button%22+src%3D%22images%2Fsml-btn.png%22+width%3D%22112%22+height%3D%2230%22+alt%3D%22%22%2F%3E%3C%2Fa%3E%0A%09%3C%2Ftd%3E%0A%3C%2Ftr%3E%0A%0A%3C%21--WRAPPEREND--%3E%3C%2Ftable%3E%3C%2Fdiv%3E%3C%21--WRAPPEREND--%3E'
   23     1        ASSIGN                                                   !1, 'sub_0_'
   24     2        INIT_FCALL_BY_NAME                                       '_format_special_tags'
          3        SEND_VAR_EX                                              !0
          4        SEND_VAR_EX                                              !1
          5        DO_FCALL                                      0  $4      
          6        ECHO                                                     $4
   45     7      > RETURN                                                   1

Function _format_special_tags:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 25
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 30
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
2 jumps found. (Code = 43) Position 1 = 36, Position 2 = 38
Branch analysis from position: 36
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 38
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
2 jumps found. (Code = 43) Position 1 = 36, Position 2 = 38
Branch analysis from position: 36
Branch analysis from position: 38
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 30
Branch analysis from position: 28
Branch analysis from position: 30
filename:       /in/8O166
function name:  _format_special_tags
number of ops:  44
compiled vars:  !0 = $html, !1 = $sub, !2 = $tags, !3 = $outer, !4 = $end_outer, !5 = $header, !6 = $wrapper_start, !7 = $wrapper_end
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   28     2        ASSIGN                                                   !2, <array>
   29     3        CONCAT                                           ~9      '%7B%25+if+forloop.counter+%3D+', !1
          4        CONCAT                                           ~10     ~9, 'range.0+%25%7D'
          5        ASSIGN                                                   !3, ~10
   30     6        ASSIGN                                                   !4, '%7B%25+endif+%25%7D'
   31     7        INIT_FCALL_BY_NAME                                       '_return_between'
          8        SEND_VAL_EX                                              '%3C%21--HEAD--%3E'
          9        SEND_VAR_EX                                              !0
         10        DO_FCALL                                      0  $13     
         11        ASSIGN                                                   !5, $13
   32    12        INIT_FCALL_BY_NAME                                       '_return_between'
         13        SEND_VAL_EX                                              '%3C%21--WRAPPERSTART--%3E'
         14        SEND_VAR_EX                                              !0
         15        DO_FCALL                                      0  $15     
         16        ASSIGN                                                   !6, $15
   34    17        INIT_FCALL_BY_NAME                                       '_return_between'
         18        SEND_VAL_EX                                              '%3C%21--WRAPPEREND--%3E'
         19        SEND_VAR_EX                                              !0
         20        DO_FCALL                                      0  $17     
         21        ASSIGN                                                   !7, $17
   35    22      > JMPZ                                                     !5, ->25
         23    >   QM_ASSIGN                                        ~19     !5
         24      > JMP                                                      ->26
         25    >   QM_ASSIGN                                        ~19     ''
         26    >   CONCAT                                           ~20     !3, ~19
         27      > JMPZ                                                     !6, ->30
         28    >   QM_ASSIGN                                        ~21     !6
         29      > JMP                                                      ->31
         30    >   QM_ASSIGN                                        ~21     ''
         31    >   CONCAT                                           ~22     ~20, ~21
         32        CONCAT                                           ~23     ~22, !4
         33        CONCAT                                           ~24     ~23, !0
         34        CONCAT                                           ~25     ~24, !3
         35      > JMPZ                                                     !7, ->38
         36    >   QM_ASSIGN                                        ~26     !7
         37      > JMP                                                      ->39
         38    >   QM_ASSIGN                                        ~26     ''
         39    >   CONCAT                                           ~27     ~25, ~26
         40        CONCAT                                           ~28     ~27, !4
         41        ASSIGN                                                   !0, ~28
   36    42      > RETURN                                                   !0
   37    43*     > RETURN                                                   null

End of function _format_special_tags

Function _return_between:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 13
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8O166
function name:  _return_between
number of ops:  16
compiled vars:  !0 = $tag, !1 = $subject, !2 = $split
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   38     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   39     2        INIT_FCALL                                               'explode'
          3        SEND_VAR                                                 !0
          4        SEND_VAR                                                 !1
          5        SEND_VAL                                                 3
          6        DO_ICALL                                         $3      
          7        ASSIGN                                                   !2, $3
   40     8        ISSET_ISEMPTY_DIM_OBJ                         0          !2, 1
          9      > JMPZ                                                     ~5, ->13
         10    >   FETCH_DIM_R                                      ~6      !2, 1
         11        QM_ASSIGN                                        ~7      ~6
         12      > JMP                                                      ->14
         13    >   QM_ASSIGN                                        ~7      <false>
         14    > > RETURN                                                   ~7
   41    15*     > RETURN                                                   null

End of function _return_between

Function _remove_between:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8O166
function name:  _remove_between
number of ops:  13
compiled vars:  !0 = $tag, !1 = $subject
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   42     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   44     2        INIT_FCALL                                               'preg_replace'
          3        CONCAT                                           ~2      '%2F', !0
          4        CONCAT                                           ~3      ~2, '.%2B%3F'
          5        CONCAT                                           ~4      ~3, !0
          6        CONCAT                                           ~5      ~4, '%2Fi'
          7        SEND_VAL                                                 ~5
          8        SEND_VAL                                                 ''
          9        SEND_VAR                                                 !1
         10        DO_ICALL                                         $6      
         11        ECHO                                                     $6
   45    12      > RETURN                                                   null

End of function _remove_between

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.64 ms | 1404 KiB | 17 Q