3v4l.org

run code in 300+ 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 = 28
Branch analysis from position: 28
2 jumps found. (Code = 44) Position 1 = 32, Position 2 = 11
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
2 jumps found. (Code = 44) Position 1 = 32, Position 2 = 11
Branch analysis from position: 32
Branch analysis from position: 11
filename:       /in/1mhYu
function name:  replace
number of ops:  34
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                                                      ->28
   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        INIT_FCALL                                               'str_replace'
         22        SEND_VAR                                                 !1
         23        SEND_VAR                                                 !5
         24        SEND_VAR                                                 !0
         25        DO_ICALL                                         $21     
         26        ASSIGN                                                   !0, $21
   11    27        PRE_INC                                                  !4
         28    >   FETCH_DIM_R                                      ~24     !2, 1
         29        COUNT                                            ~25     ~24
         30        IS_SMALLER                                               !4, ~25
         31      > JMPNZ                                                    ~26, ->11
   16    32    > > RETURN                                                   !0
   17    33*     > RETURN                                                   null

End of function replace

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
128.31 ms | 1407 KiB | 20 Q