3v4l.org

run code in 300+ PHP versions simultaneously
<?php function replace($row){ $replaced = preg_replace_callback("~(\<span class=\"itemopener\"\>)(\d{2})\s(top\</span\>.*\<span class=\"allopener\"\>).{3}(\</span\>)~iU", function($matches){ $str = $matches[1] . $matches[3] . $matches[2] . $matches[4]; return $str; }, $row); return $replaced; } $s = '<span class="itemopener">82 top</span>&nbsp;<span class="allopener">all</span>'; $replaced = replace($s); echo "<pre>" . print_r($replaced, 1) . "</pre>"; exit();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 79) Position 1 = -2
filename:       /in/9glo4
function name:  (null)
number of ops:  14
compiled vars:  !0 = $s, !1 = $replaced
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   ASSIGN                                                   !0, '%3Cspan+class%3D%22itemopener%22%3E82+top%3C%2Fspan%3E%26nbsp%3B%3Cspan+class%3D%22allopener%22%3Eall%3C%2Fspan%3E'
   14     1        INIT_FCALL                                               'replace'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0  $3      
          4        ASSIGN                                                   !1, $3
   16     5        INIT_FCALL                                               'print_r'
          6        SEND_VAR                                                 !1
          7        SEND_VAL                                                 1
          8        DO_ICALL                                         $5      
          9        CONCAT                                           ~6      '%3Cpre%3E', $5
         10        CONCAT                                           ~7      ~6, '%3C%2Fpre%3E'
         11        ECHO                                                     ~7
   17    12      > EXIT                                                     
         13*     > RETURN                                                   1

Function replace:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9glo4
function name:  replace
number of ops:  10
compiled vars:  !0 = $row, !1 = $replaced
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    6     1        INIT_FCALL                                               'preg_replace_callback'
          2        SEND_VAL                                                 '%7E%28%5C%3Cspan+class%3D%22itemopener%22%5C%3E%29%28%5Cd%7B2%7D%29%5Cs%28top%5C%3C%2Fspan%5C%3E.%2A%5C%3Cspan+class%3D%22allopener%22%5C%3E%29.%7B3%7D%28%5C%3C%2Fspan%5C%3E%29%7EiU'
          3        DECLARE_LAMBDA_FUNCTION                          ~2      [0]
    9     4        SEND_VAL                                                 ~2
          5        SEND_VAR                                                 !0
    6     6        DO_ICALL                                         $3      
          7        ASSIGN                                                   !1, $3
   10     8      > RETURN                                                   !1
   11     9*     > RETURN                                                   null


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

End of Dynamic Function 0

End of function replace

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
188.41 ms | 1468 KiB | 16 Q