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

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
168.04 ms | 1400 KiB | 21 Q