3v4l.org

run code in 500+ PHP versions simultaneously
<?php function replace($originalcontent){ $replacethis = '(<a href=\"([0-9]{2})\\.htm\">)'; $linkArr = []; $lessonNo = preg_match_all($replacethis, $originalcontent, $linkArr); for($x = 0; $x < count($linkArr[1]); $x++) { $replacethis = '<a href="'.$linkArr[1][$x].'.htm">'; $replacewith = '<a style="cursor:pointer;" onclick="gotoScrollExercise('. $linkArr[1][$x] .'); return false;">'; $originalcontent = str_replace($replacethis, $replacewith, $originalcontent); } return $originalcontent; } $originalcontent = '<a href="04.htm">'; $originalcontent = replace($originalcontent); var_dump($originalcontent);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1mhYu
function name:  (null)
number of ops:  9
compiled vars:  !0 = $originalcontent
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   21     0  E >   ASSIGN                                                       !0, '%3Ca+href%3D%2204.htm%22%3E'
   23     1        INIT_FCALL                                                   'replace'
          2        SEND_VAR                                                     !0
          3        DO_FCALL                                          0  $2      
          4        ASSIGN                                                       !0, $2
   25     5        INIT_FCALL                                                   'var_dump'
          6        SEND_VAR                                                     !0
          7        DO_ICALL                                                     
          8      > RETURN                                                       1

Function replace:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
2 jumps found. (Code = 44) Position 1 = 29, Position 2 = 11
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
2 jumps found. (Code = 44) Position 1 = 29, Position 2 = 11
Branch analysis from position: 29
Branch analysis from position: 11
filename:       /in/1mhYu
function name:  replace
number of ops:  31
compiled vars:  !0 = $originalcontent, !1 = $replacethis, !2 = $linkArr, !3 = $lessonNo, !4 = $x, !5 = $replacewith
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    5     0  E >   RECV                                                 !0      
    6     1        ASSIGN                                                       !1, '%28%3Ca+href%3D%5C%22%28%5B0-9%5D%7B2%7D%29%5C.htm%5C%22%3E%29'
    7     2        ASSIGN                                                       !2, <array>
    9     3        INIT_FCALL                                                   'preg_match_all'
          4        SEND_VAR                                                     !1
          5        SEND_VAR                                                     !0
          6        SEND_REF                                                     !2
          7        DO_ICALL                                             $8      
          8        ASSIGN                                                       !3, $8
   11     9        ASSIGN                                                       !4, 0
         10      > JMP                                                          ->25
   12    11    >   FETCH_DIM_R                                          ~11     !2, 1
         12        FETCH_DIM_R                                          ~12     ~11, !4
         13        CONCAT                                               ~13     '%3Ca+href%3D%22', ~12
         14        CONCAT                                               ~14     ~13, '.htm%22%3E'
         15        ASSIGN                                                       !1, ~14
   13    16        FETCH_DIM_R                                          ~16     !2, 1
         17        FETCH_DIM_R                                          ~17     ~16, !4
         18        CONCAT                                               ~18     '%3Ca+style%3D%22cursor%3Apointer%3B%22+onclick%3D%22gotoScrollExercise%28', ~17
         19        CONCAT                                               ~19     ~18, '%29%3B+return+false%3B%22%3E'
         20        ASSIGN                                                       !5, ~19
   14    21        FRAMELESS_ICALL_3                str_replace         ~21     !1, !5
         22        OP_DATA                                                      !0
         23        ASSIGN                                                       !0, ~21
   11    24        PRE_INC                                                      !4
         25    >   FETCH_DIM_R                                          ~24     !2, 1
         26        COUNT                                                ~25     ~24
         27        IS_SMALLER                                                   !4, ~25
         28      > JMPNZ                                                        ~26, ->11
   16    29    > > RETURN                                                       !0
   17    30*     > RETURN                                                       null

End of function replace

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
169.13 ms | 3305 KiB | 16 Q