3v4l.org

run code in 300+ PHP versions simultaneously
<?php $originalString = 'Her (III.1) was the age of 2 years and 11 months. (shoulder a 4/5)'; $findStringArray = array("age", "(III.1)", "2", "months", "4"); $words = explode(" ",$originalString); for($x = 0; $x<count($words); $x++) { foreach($findStringArray as $key => $value) { $originalString = preg_replace('/\b('.preg_quote($value).')\b/i', "__", $originalString); if ($words[$x] == $value) { $words[$x] = preg_replace('/\b('.preg_quote($value).')\b/i', "__", $words[$x]); } } } $newstring = implode(" ", $words); echo $newstring;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 42
Branch analysis from position: 42
2 jumps found. (Code = 44) Position 1 = 45, Position 2 = 9
Branch analysis from position: 45
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 40
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 40
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 39
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 39
Branch analysis from position: 40
2 jumps found. (Code = 44) Position 1 = 45, Position 2 = 9
Branch analysis from position: 45
Branch analysis from position: 9
Branch analysis from position: 40
filename:       /in/eZFDF
function name:  (null)
number of ops:  52
compiled vars:  !0 = $originalString, !1 = $findStringArray, !2 = $words, !3 = $x, !4 = $value, !5 = $key, !6 = $newstring
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'Her+%28III.1%29+was+the+age+of+2+years+and+11+months.+%28shoulder+a+4%2F5%29'
    4     1        ASSIGN                                                   !1, <array>
    5     2        INIT_FCALL                                               'explode'
          3        SEND_VAL                                                 '+'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $9      
          6        ASSIGN                                                   !2, $9
    6     7        ASSIGN                                                   !3, 0
          8      > JMP                                                      ->42
    7     9    > > FE_RESET_R                                       $12     !1, ->40
         10    > > FE_FETCH_R                                       ~13     $12, !4, ->40
         11    >   ASSIGN                                                   !5, ~13
    8    12        INIT_FCALL                                               'preg_replace'
         13        INIT_FCALL                                               'preg_quote'
         14        SEND_VAR                                                 !4
         15        DO_ICALL                                         $15     
         16        CONCAT                                           ~16     '%2F%5Cb%28', $15
         17        CONCAT                                           ~17     ~16, '%29%5Cb%2Fi'
         18        SEND_VAL                                                 ~17
         19        SEND_VAL                                                 '__'
         20        SEND_VAR                                                 !0
         21        DO_ICALL                                         $18     
         22        ASSIGN                                                   !0, $18
    9    23        FETCH_DIM_R                                      ~20     !2, !3
         24        IS_EQUAL                                                 !4, ~20
         25      > JMPZ                                                     ~21, ->39
   10    26    >   INIT_FCALL                                               'preg_replace'
         27        INIT_FCALL                                               'preg_quote'
         28        SEND_VAR                                                 !4
         29        DO_ICALL                                         $23     
         30        CONCAT                                           ~24     '%2F%5Cb%28', $23
         31        CONCAT                                           ~25     ~24, '%29%5Cb%2Fi'
         32        SEND_VAL                                                 ~25
         33        SEND_VAL                                                 '__'
         34        FETCH_DIM_R                                      ~26     !2, !3
         35        SEND_VAL                                                 ~26
         36        DO_ICALL                                         $27     
         37        ASSIGN_DIM                                               !2, !3
         38        OP_DATA                                                  $27
    7    39    > > JMP                                                      ->10
         40    >   FE_FREE                                                  $12
    6    41        PRE_INC                                                  !3
         42    >   COUNT                                            ~29     !2
         43        IS_SMALLER                                               !3, ~29
         44      > JMPNZ                                                    ~30, ->9
   14    45    >   INIT_FCALL                                               'implode'
         46        SEND_VAL                                                 '+'
         47        SEND_VAR                                                 !2
         48        DO_ICALL                                         $31     
         49        ASSIGN                                                   !6, $31
   15    50        ECHO                                                     !6
         51      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.84 ms | 1400 KiB | 21 Q