3v4l.org

run code in 300+ 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-finned 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 = '@\(.*?\)@'; $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/qubvh
function name:  (null)
number of ops:  30
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-finned+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
   20    12        INIT_FCALL                                               'removeparentheses'
         13        SEND_VAR                                                 !3
         14        DO_FCALL                                      0  $10     
         15        ASSIGN                                                   !3, $10
   21    16        INIT_FCALL                                               'str_replace'
         17        INIT_FCALL                                               'array_keys'
         18        SEND_VAR                                                 !2
         19        DO_ICALL                                         $12     
         20        SEND_VAR                                                 $12
         21        INIT_FCALL                                               'array_values'
         22        SEND_VAR                                                 !2
         23        DO_ICALL                                         $13     
         24        SEND_VAR                                                 $13
         25        SEND_VAR                                                 !3
         26        DO_ICALL                                         $14     
         27        ASSIGN                                                   !3, $14
   22    28        ECHO                                                     !3
         29      > 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/qubvh
function name:  {closure}
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/qubvh
function name:  removeParentheses
number of ops:  22
compiled vars:  !0 = $content, !1 = $pattern
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
   14     1        ASSIGN                                                   !1, '%40%5C%28.%2A%3F%5C%29%40'
   15     2        INIT_FCALL                                               'preg_replace'
          3        SEND_VAR                                                 !1
          4        SEND_VAL                                                 ''
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $3      
          7        ASSIGN                                                   !0, $3
   16     8        INIT_FCALL                                               'str_replace'
          9        SEND_VAL                                                 '+.'
         10        SEND_VAL                                                 '.'
         11        SEND_VAR                                                 !0
         12        DO_ICALL                                         $5      
         13        ASSIGN                                                   !0, $5
   17    14        INIT_FCALL                                               'str_replace'
         15        SEND_VAL                                                 '++'
         16        SEND_VAL                                                 '+'
         17        SEND_VAR                                                 !0
         18        DO_ICALL                                         $7      
         19        ASSIGN                                                   !0, $7
   18    20      > RETURN                                                   !0
   19    21*     > RETURN                                                   null

End of function removeparentheses

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
124.7 ms | 1009 KiB | 19 Q