3v4l.org

run code in 500+ PHP versions simultaneously
<?php $string = '<p> The <b>Sarcopterygii</b> or <b>lobe-finned fish</b> (from Greek σαρξ <i>sarx</i>, flesh, and πτερυξ <i>pteryx</i>, fin) – sometimes considered synonymous with <b>Crossopterygii</b> ("fringe-f(i)nned fish", from Greek κροσσός <i>krossos</i>, fringe) – constitute a <a href="/wiki/Clade" title="Clade">clade</a> (traditionally a <a href="/wiki/Class_(biology)" title="Class (biology)">class</a> or subclass) of the <a href="/wiki/Osteichthyes" title="Osteichthyes">bony fish</a>, though a strict <a href="/wiki/Cladistic" class="mw-redirect" title="Cladistic">cladistic</a> view includes the terrestrial <a href="/wiki/Vertebrate" title="Vertebrate">vertebrates</a>. </p>'; $occurrences = 0; $replacements = []; $replacedString = preg_replace_callback("/<a .*?>.*?<\/a>/i", function($el) use (&$occurrences, &$replacements) { $replacements["|||".$occurrences] = $el[0]; // the ||| are just to avoid unwanted matches return "|||".$occurrences++; }, $string); function removeParentheses( $content ) { $pattern = '@\(([^()]|(?R))*\)@'; $content = preg_replace( $pattern, '', $content ); $content = str_replace( ' .', '.', $content ); $content = str_replace( ' ', ' ', $content ); return $content; } $replacedString = removeParentheses($replacedString); $replacedString = str_replace(array_keys($replacements), array_values($replacements), $replacedString); echo $replacedString;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NgrU0
function name:  (null)
number of ops:  27
compiled vars:  !0 = $string, !1 = $occurrences, !2 = $replacements, !3 = $replacedString
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, '%3Cp%3E%0AThe+%3Cb%3ESarcopterygii%3C%2Fb%3E+or+%3Cb%3Elobe-finned+fish%3C%2Fb%3E+%28from+Greek+%CF%83%CE%B1%CF%81%CE%BE+%3Ci%3Esarx%3C%2Fi%3E%2C+flesh%2C+and+%CF%80%CF%84%CE%B5%CF%81%CF%85%CE%BE+%3Ci%3Epteryx%3C%2Fi%3E%2C+fin%29+%E2%80%93+sometimes+considered+synonymous+with+%3Cb%3ECrossopterygii%3C%2Fb%3E+%28%22fringe-f%28i%29nned+fish%22%2C+from+Greek+%CE%BA%CF%81%CE%BF%CF%83%CF%83%CF%8C%CF%82+%3Ci%3Ekrossos%3C%2Fi%3E%2C+fringe%29+%E2%80%93+constitute+a+%3Ca+href%3D%22%2Fwiki%2FClade%22+title%3D%22Clade%22%3Eclade%3C%2Fa%3E+%28traditionally+a+%3Ca+href%3D%22%2Fwiki%2FClass_%28biology%29%22+title%3D%22Class+%28biology%29%22%3Eclass%3C%2Fa%3E+or+subclass%29+of+the+%3Ca+href%3D%22%2Fwiki%2FOsteichthyes%22+title%3D%22Osteichthyes%22%3Ebony+fish%3C%2Fa%3E%2C+though+a+strict+%3Ca+href%3D%22%2Fwiki%2FCladistic%22+class%3D%22mw-redirect%22+title%3D%22Cladistic%22%3Ecladistic%3C%2Fa%3E+view+includes+the+terrestrial+%3Ca+href%3D%22%2Fwiki%2FVertebrate%22+title%3D%22Vertebrate%22%3Evertebrates%3C%2Fa%3E.%0A%3C%2Fp%3E'
    6     1        ASSIGN                                                       !1, 0
    7     2        ASSIGN                                                       !2, <array>
    8     3        INIT_FCALL                                                   'preg_replace_callback'
          4        SEND_VAL                                                     '%2F%3Ca+.%2A%3F%3E.%2A%3F%3C%5C%2Fa%3E%2Fi'
          5        DECLARE_LAMBDA_FUNCTION                              ~7      [0]
          6        BIND_LEXICAL                                                 ~7, !1
          7        BIND_LEXICAL                                                 ~7, !2
   11     8        SEND_VAL                                                     ~7
          9        SEND_VAR                                                     !0
    8    10        DO_ICALL                                             $8      
         11        ASSIGN                                                       !3, $8
   19    12        INIT_FCALL                                                   'removeparentheses'
         13        SEND_VAR                                                     !3
         14        DO_FCALL                                          0  $10     
         15        ASSIGN                                                       !3, $10
   20    16        INIT_FCALL                                                   'array_keys'
         17        SEND_VAR                                                     !2
         18        DO_ICALL                                             $12     
         19        INIT_FCALL                                                   'array_values'
         20        SEND_VAR                                                     !2
         21        DO_ICALL                                             $13     
         22        FRAMELESS_ICALL_3                str_replace         ~14     $12, $13
         23        OP_DATA                                                      !3
         24        ASSIGN                                                       !3, ~14
   21    25        ECHO                                                         !3
         26      > RETURN                                                       1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NgrU0
function name:  {closure:/in/NgrU0:8}
number of ops:  11
compiled vars:  !0 = $el, !1 = $occurrences, !2 = $replacements
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    8     0  E >   RECV                                                 !0      
          1        BIND_STATIC                                                  !1
          2        BIND_STATIC                                                  !2
    9     3        CONCAT                                               ~3      '%7C%7C%7C', !1
          4        FETCH_DIM_R                                          ~5      !0, 0
          5        ASSIGN_DIM                                                   !2, ~3
          6        OP_DATA                                                      ~5
   10     7        POST_INC                                             ~6      !1
          8        CONCAT                                               ~7      '%7C%7C%7C', ~6
          9      > RETURN                                                       ~7
   11    10*     > RETURN                                                       null

End of Dynamic Function 0

Function removeparentheses:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NgrU0
function name:  removeParentheses
number of ops:  13
compiled vars:  !0 = $content, !1 = $pattern
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   12     0  E >   RECV                                                 !0      
   13     1        ASSIGN                                                       !1, '%40%5C%28%28%5B%5E%28%29%5D%7C%28%3FR%29%29%2A%5C%29%40'
   14     2        FRAMELESS_ICALL_3                preg_replace        ~3      !1, ''
          3        OP_DATA                                                      !0
          4        ASSIGN                                                       !0, ~3
   15     5        FRAMELESS_ICALL_3                str_replace         ~5      '+.', '.'
          6        OP_DATA                                                      !0
          7        ASSIGN                                                       !0, ~5
   16     8        FRAMELESS_ICALL_3                str_replace         ~7      '++', '+'
          9        OP_DATA                                                      !0
         10        ASSIGN                                                       !0, ~7
   17    11      > RETURN                                                       !0
   18    12*     > RETURN                                                       null

End of function removeparentheses

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
171.81 ms | 2712 KiB | 17 Q