3v4l.org

run code in 300+ PHP versions simultaneously
<?php $row = array(); $row['title'] = 'Mr Smith'; $row['surname'] = 'Smith'; if ( isset($row['title']) && isset($row['surname']) ) { if ( '' !== trim($row['title']) && '' !== trim($row['surname']) ) { $titleParts = explode(' ',$row['title']); if ( count($titleParts) > 1 ) { if ( -1 !== strpos($row['title'],$row['surname']) ) { foreach ( $titleParts as $index => $titlePart ) { if ( $row['surname'] === $titlePart ) { unset($titleParts[$index]); } } } $row['title'] = trim(implode(' ',$titleParts)); echo $row['title']; } } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 7, Position 2 = 9
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 60
Branch analysis from position: 10
2 jumps found. (Code = 46) Position 1 = 16, Position 2 = 22
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 60
Branch analysis from position: 23
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 60
Branch analysis from position: 32
2 jumps found. (Code = 43) Position 1 = 40, Position 2 = 49
Branch analysis from position: 40
2 jumps found. (Code = 77) Position 1 = 41, Position 2 = 48
Branch analysis from position: 41
2 jumps found. (Code = 78) Position 1 = 42, Position 2 = 48
Branch analysis from position: 42
2 jumps found. (Code = 43) Position 1 = 46, Position 2 = 47
Branch analysis from position: 46
1 jumps found. (Code = 42) Position 1 = 41
Branch analysis from position: 41
Branch analysis from position: 47
Branch analysis from position: 48
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 48
Branch analysis from position: 49
Branch analysis from position: 60
Branch analysis from position: 60
Branch analysis from position: 22
Branch analysis from position: 60
Branch analysis from position: 9
filename:       /in/21e0B
function name:  (null)
number of ops:  61
compiled vars:  !0 = $row, !1 = $titleParts, !2 = $titlePart, !3 = $index
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    3     1        ASSIGN_DIM                                               !0, 'title'
          2        OP_DATA                                                  'Mr+Smith'
    4     3        ASSIGN_DIM                                               !0, 'surname'
          4        OP_DATA                                                  'Smith'
    5     5        ISSET_ISEMPTY_DIM_OBJ                         0  ~7      !0, 'title'
          6      > JMPZ_EX                                          ~7      ~7, ->9
          7    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~8      !0, 'surname'
          8        BOOL                                             ~7      ~8
          9    > > JMPZ                                                     ~7, ->60
    6    10    >   INIT_FCALL                                               'trim'
         11        FETCH_DIM_R                                      ~9      !0, 'title'
         12        SEND_VAL                                                 ~9
         13        DO_ICALL                                         $10     
         14        IS_NOT_IDENTICAL                                 ~11     $10, ''
         15      > JMPZ_EX                                          ~11     ~11, ->22
         16    >   INIT_FCALL                                               'trim'
         17        FETCH_DIM_R                                      ~12     !0, 'surname'
         18        SEND_VAL                                                 ~12
         19        DO_ICALL                                         $13     
         20        IS_NOT_IDENTICAL                                 ~14     $13, ''
         21        BOOL                                             ~11     ~14
         22    > > JMPZ                                                     ~11, ->60
    7    23    >   INIT_FCALL                                               'explode'
         24        SEND_VAL                                                 '+'
         25        FETCH_DIM_R                                      ~15     !0, 'title'
         26        SEND_VAL                                                 ~15
         27        DO_ICALL                                         $16     
         28        ASSIGN                                                   !1, $16
    8    29        COUNT                                            ~18     !1
         30        IS_SMALLER                                               1, ~18
         31      > JMPZ                                                     ~19, ->60
    9    32    >   INIT_FCALL                                               'strpos'
         33        FETCH_DIM_R                                      ~20     !0, 'title'
         34        SEND_VAL                                                 ~20
         35        FETCH_DIM_R                                      ~21     !0, 'surname'
         36        SEND_VAL                                                 ~21
         37        DO_ICALL                                         $22     
         38        IS_NOT_IDENTICAL                                         $22, -1
         39      > JMPZ                                                     ~23, ->49
   10    40    > > FE_RESET_R                                       $24     !1, ->48
         41    > > FE_FETCH_R                                       ~25     $24, !2, ->48
         42    >   ASSIGN                                                   !3, ~25
   11    43        FETCH_DIM_R                                      ~27     !0, 'surname'
         44        IS_IDENTICAL                                             !2, ~27
         45      > JMPZ                                                     ~28, ->47
   12    46    >   UNSET_DIM                                                !1, !3
   10    47    > > JMP                                                      ->41
         48    >   FE_FREE                                                  $24
   16    49    >   INIT_FCALL                                               'trim'
         50        INIT_FCALL                                               'implode'
         51        SEND_VAL                                                 '+'
         52        SEND_VAR                                                 !1
         53        DO_ICALL                                         $30     
         54        SEND_VAR                                                 $30
         55        DO_ICALL                                         $31     
         56        ASSIGN_DIM                                               !0, 'title'
         57        OP_DATA                                                  $31
   17    58        FETCH_DIM_R                                      ~32     !0, 'title'
         59        ECHO                                                     ~32
   20    60    > > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.89 ms | 1400 KiB | 21 Q