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) { $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 = 28
Branch analysis from position: 28
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 9
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 26
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 26
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 26
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 9
Branch analysis from position: 31
Branch analysis from position: 9
Branch analysis from position: 26
filename:       /in/7dOfG
function name:  (null)
number of ops:  38
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                                                      ->28
    7     9    > > FE_RESET_R                                       $12     !1, ->26
         10    > > FE_FETCH_R                                       ~13     $12, !4, ->26
         11    >   ASSIGN                                                   !5, ~13
    8    12        INIT_FCALL                                               'preg_replace'
         13        INIT_FCALL                                               'preg_quote'
         14        SEND_VAR                                                 !4
         15        DO_ICALL                                         $16     
         16        CONCAT                                           ~17     '%2F%5Cb%28', $16
         17        CONCAT                                           ~18     ~17, '%29%5Cb%2Fi'
         18        SEND_VAL                                                 ~18
         19        SEND_VAL                                                 '__'
         20        FETCH_DIM_R                                      ~19     !2, !3
         21        SEND_VAL                                                 ~19
         22        DO_ICALL                                         $20     
         23        ASSIGN_DIM                                               !2, !3
         24        OP_DATA                                                  $20
    7    25      > JMP                                                      ->10
         26    >   FE_FREE                                                  $12
    6    27        PRE_INC                                                  !3
         28    >   COUNT                                            ~22     !2
         29        IS_SMALLER                                               !3, ~22
         30      > JMPNZ                                                    ~23, ->9
   11    31    >   INIT_FCALL                                               'implode'
         32        SEND_VAL                                                 '+'
         33        SEND_VAR                                                 !2
         34        DO_ICALL                                         $24     
         35        ASSIGN                                                   !6, $24
   12    36        ECHO                                                     !6
         37      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.75 ms | 1400 KiB | 21 Q