3v4l.org

run code in 300+ PHP versions simultaneously
<?php $expression = "/(?J)\b(?: (?<obj>i)(?:(?<part>'m)|\s(?<part>am|was))? |(?<obj>you|they)(?:(?<part>'re)|\s(?<part>are|were))? |(?<obj>it|he|she)(?:(?<part>'s)|\s(?<part>is|was))? |(?<obj>(my|your|it)sel(f|ves)) )\b/uix"; $message = "that you are not who you think you're but I'm not myself either"; echo $output = preg_replace_callback($expression, function ($matches){ $o = ''; $object = strtolower($matches['obj']); switch($object){ case 'i': $o = 'you'; break; case 'you': $o = 'I'; break; case 'yourself': $o = 'myself'; break; case 'myself': $o = 'yourself'; break; default: $o = $object; } if(isset($matches['part'])){ switch($part = strtolower($matches['part'])){ case "'re": case "are": if($object == 'you') $o .= ' am'; break; case 'am': $o .= ' are'; break; case "'m": $o .= "'re"; break; case 'was': if(!in_array($object, ['he','she','it'])) $o .= ' were'; break; case 'were': if($object == 'you') $o .= ' was'; break; } } return $o; }, $message );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/aZJID
function name:  (null)
number of ops:  11
compiled vars:  !0 = $expression, !1 = $message, !2 = $output
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '%2F%28%3FJ%29%5Cb%28%3F%3A%0A%28%3F%3Cobj%3Ei%29%28%3F%3A%28%3F%3Cpart%3E%27m%29%7C%5Cs%28%3F%3Cpart%3Eam%7Cwas%29%29%3F%0A%7C%28%3F%3Cobj%3Eyou%7Cthey%29%28%3F%3A%28%3F%3Cpart%3E%27re%29%7C%5Cs%28%3F%3Cpart%3Eare%7Cwere%29%29%3F%0A%7C%28%3F%3Cobj%3Eit%7Che%7Cshe%29%28%3F%3A%28%3F%3Cpart%3E%27s%29%7C%5Cs%28%3F%3Cpart%3Eis%7Cwas%29%29%3F%0A%7C%28%3F%3Cobj%3E%28my%7Cyour%7Cit%29sel%28f%7Cves%29%29%0A%29%5Cb%2Fuix'
    9     1        ASSIGN                                                   !1, 'that+you+are+not+who+you+think+you%27re+but+I%27m+not+myself+either'
   10     2        INIT_FCALL                                               'preg_replace_callback'
          3        SEND_VAR                                                 !0
   11     4        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FaZJID%3A11%240'
   58     5        SEND_VAL                                                 ~5
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                         $6      
   10     8        ASSIGN                                           ~7      !2, $6
          9        ECHO                                                     ~7
   59    10      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FaZJID%3A11%240:
Finding entry points
Branch analysis from position: 0
6 jumps found. (Code = 188) Position 1 = 17, Position 2 = 19, Position 3 = 21, Position 4 = 23, Position 5 = 25, Position 6 = 8
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 65
Branch analysis from position: 28
8 jumps found. (Code = 188) Position 1 = 47, Position 2 = 47, Position 3 = 51, Position 4 = 53, Position 5 = 55, Position 6 = 60, Position 7 = 64, Position 8 = 34
Branch analysis from position: 47
2 jumps found. (Code = 43) Position 1 = 49, Position 2 = 50
Branch analysis from position: 49
1 jumps found. (Code = 42) Position 1 = 64
Branch analysis from position: 64
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 50
Branch analysis from position: 47
Branch analysis from position: 51
1 jumps found. (Code = 42) Position 1 = 64
Branch analysis from position: 64
Branch analysis from position: 53
1 jumps found. (Code = 42) Position 1 = 64
Branch analysis from position: 64
Branch analysis from position: 55
2 jumps found. (Code = 43) Position 1 = 58, Position 2 = 59
Branch analysis from position: 58
1 jumps found. (Code = 42) Position 1 = 64
Branch analysis from position: 64
Branch analysis from position: 59
Branch analysis from position: 60
2 jumps found. (Code = 43) Position 1 = 62, Position 2 = 63
Branch analysis from position: 62
1 jumps found. (Code = 42) Position 1 = 64
Branch analysis from position: 64
Branch analysis from position: 63
Branch analysis from position: 64
Branch analysis from position: 34
2 jumps found. (Code = 44) Position 1 = 36, Position 2 = 47
Branch analysis from position: 36
2 jumps found. (Code = 44) Position 1 = 38, Position 2 = 47
Branch analysis from position: 38
2 jumps found. (Code = 44) Position 1 = 40, Position 2 = 51
Branch analysis from position: 40
2 jumps found. (Code = 44) Position 1 = 42, Position 2 = 53
Branch analysis from position: 42
2 jumps found. (Code = 44) Position 1 = 44, Position 2 = 55
Branch analysis from position: 44
2 jumps found. (Code = 44) Position 1 = 46, Position 2 = 60
Branch analysis from position: 46
1 jumps found. (Code = 42) Position 1 = 64
Branch analysis from position: 64
Branch analysis from position: 60
Branch analysis from position: 55
Branch analysis from position: 53
Branch analysis from position: 51
Branch analysis from position: 47
Branch analysis from position: 47
Branch analysis from position: 65
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 65
Branch analysis from position: 28
Branch analysis from position: 65
Branch analysis from position: 8
2 jumps found. (Code = 44) Position 1 = 10, Position 2 = 17
Branch analysis from position: 10
2 jumps found. (Code = 44) Position 1 = 12, Position 2 = 19
Branch analysis from position: 12
2 jumps found. (Code = 44) Position 1 = 14, Position 2 = 21
Branch analysis from position: 14
2 jumps found. (Code = 44) Position 1 = 16, Position 2 = 23
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
Branch analysis from position: 23
Branch analysis from position: 21
Branch analysis from position: 19
Branch analysis from position: 17
filename:       /in/aZJID
function name:  {closure}
number of ops:  67
compiled vars:  !0 = $matches, !1 = $o, !2 = $object, !3 = $part
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
   12     1        ASSIGN                                                   !1, ''
   13     2        INIT_FCALL                                               'strtolower'
          3        FETCH_DIM_R                                      ~5      !0, 'obj'
          4        SEND_VAL                                                 ~5
          5        DO_ICALL                                         $6      
          6        ASSIGN                                                   !2, $6
   15     7      > SWITCH_STRING                                            !2, [ 'i':->17, 'you':->19, 'yourself':->21, 'myself':->23, ], ->25
   16     8    >   IS_EQUAL                                                 !2, 'i'
          9      > JMPNZ                                                    ~8, ->17
   19    10    >   IS_EQUAL                                                 !2, 'you'
         11      > JMPNZ                                                    ~8, ->19
   22    12    >   IS_EQUAL                                                 !2, 'yourself'
         13      > JMPNZ                                                    ~8, ->21
   25    14    >   IS_EQUAL                                                 !2, 'myself'
         15      > JMPNZ                                                    ~8, ->23
         16    > > JMP                                                      ->25
   17    17    >   ASSIGN                                                   !1, 'you'
   18    18      > JMP                                                      ->26
   20    19    >   ASSIGN                                                   !1, 'I'
   21    20      > JMP                                                      ->26
   23    21    >   ASSIGN                                                   !1, 'myself'
   24    22      > JMP                                                      ->26
   26    23    >   ASSIGN                                                   !1, 'yourself'
   27    24      > JMP                                                      ->26
   29    25    >   ASSIGN                                                   !1, !2
   32    26    >   ISSET_ISEMPTY_DIM_OBJ                         0          !0, 'part'
         27      > JMPZ                                                     ~14, ->65
   33    28    >   INIT_FCALL                                               'strtolower'
         29        FETCH_DIM_R                                      ~15     !0, 'part'
         30        SEND_VAL                                                 ~15
         31        DO_ICALL                                         $16     
         32        ASSIGN                                           ~17     !3, $16
         33      > SWITCH_STRING                                            ~17, [ '%27re':->47, 'are':->47, 'am':->51, '%27m':->53, 'was':->55, 'were':->60, ], ->64
   34    34    >   CASE                                                     ~17, '%27re'
         35      > JMPNZ                                                    ~18, ->47
   35    36    >   CASE                                                     ~17, 'are'
         37      > JMPNZ                                                    ~18, ->47
   39    38    >   CASE                                                     ~17, 'am'
         39      > JMPNZ                                                    ~18, ->51
   42    40    >   CASE                                                     ~17, '%27m'
         41      > JMPNZ                                                    ~18, ->53
   45    42    >   CASE                                                     ~17, 'was'
         43      > JMPNZ                                                    ~18, ->55
   50    44    >   CASE                                                     ~17, 'were'
         45      > JMPNZ                                                    ~18, ->60
         46    > > JMP                                                      ->64
   36    47    >   IS_EQUAL                                                 !2, 'you'
         48      > JMPZ                                                     ~19, ->50
   37    49    >   ASSIGN_OP                                     8          !1, '+am'
   38    50    > > JMP                                                      ->64
   40    51    >   ASSIGN_OP                                     8          !1, '+are'
   41    52      > JMP                                                      ->64
   43    53    >   ASSIGN_OP                                     8          !1, '%27re'
   44    54      > JMP                                                      ->64
   46    55    >   IN_ARRAY                                         ~23     !2, <array>
         56        BOOL_NOT                                         ~24     ~23
         57      > JMPZ                                                     ~24, ->59
   47    58    >   ASSIGN_OP                                     8          !1, '+were'
   49    59    > > JMP                                                      ->64
   51    60    >   IS_EQUAL                                                 !2, 'you'
         61      > JMPZ                                                     ~26, ->63
   52    62    >   ASSIGN_OP                                     8          !1, '+was'
   54    63    > > JMP                                                      ->64
         64    >   FREE                                                     ~17
   57    65    > > RETURN                                                   !1
   58    66*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FaZJID%3A11%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
185.34 ms | 1404 KiB | 17 Q