3v4l.org

run code in 300+ PHP versions simultaneously
<?php $exception = ['will not be '=>'will__not__be ', 'will not ' => 'will__not ']; function f($string, $exception){ $newString = strtr($string, $exception); dump($newString); $array = explode(' ', $newString); if( $string !== $newString){ $array = array_combine($array, $array); $flip = array_map('trim', array_flip(array_map('trim', $exception))); $array = array_replace($array, array_intersect_key($flip, $array)); } return array_values($array); } var_dump(f('They will not begin', $exception)); var_dump(f('Will I love?', $exception)); var_dump(f('I will love.', $exception)); var_dump(f('I will not love.', $exception)); var_dump(f('Do I love?', $exception));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ik152
function name:  (null)
number of ops:  37
compiled vars:  !0 = $exception
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   17     1        INIT_FCALL                                               'var_dump'
          2        INIT_FCALL                                               'f'
          3        SEND_VAL                                                 'They+will+not+begin'
          4        SEND_VAR                                                 !0
          5        DO_FCALL                                      0  $2      
          6        SEND_VAR                                                 $2
          7        DO_ICALL                                                 
   18     8        INIT_FCALL                                               'var_dump'
          9        INIT_FCALL                                               'f'
         10        SEND_VAL                                                 'Will+I+love%3F'
         11        SEND_VAR                                                 !0
         12        DO_FCALL                                      0  $4      
         13        SEND_VAR                                                 $4
         14        DO_ICALL                                                 
   19    15        INIT_FCALL                                               'var_dump'
         16        INIT_FCALL                                               'f'
         17        SEND_VAL                                                 'I+will+love.'
         18        SEND_VAR                                                 !0
         19        DO_FCALL                                      0  $6      
         20        SEND_VAR                                                 $6
         21        DO_ICALL                                                 
   20    22        INIT_FCALL                                               'var_dump'
         23        INIT_FCALL                                               'f'
         24        SEND_VAL                                                 'I+will+not+love.'
         25        SEND_VAR                                                 !0
         26        DO_FCALL                                      0  $8      
         27        SEND_VAR                                                 $8
         28        DO_ICALL                                                 
   21    29        INIT_FCALL                                               'var_dump'
         30        INIT_FCALL                                               'f'
         31        SEND_VAL                                                 'Do+I+love%3F'
         32        SEND_VAR                                                 !0
         33        DO_FCALL                                      0  $10     
         34        SEND_VAR                                                 $10
         35        DO_ICALL                                                 
         36      > RETURN                                                   1

Function f:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 43
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 43
filename:       /in/ik152
function name:  f
number of ops:  48
compiled vars:  !0 = $string, !1 = $exception, !2 = $newString, !3 = $array, !4 = $flip
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    6     2        INIT_FCALL                                               'strtr'
          3        SEND_VAR                                                 !0
          4        SEND_VAR                                                 !1
          5        DO_ICALL                                         $5      
          6        ASSIGN                                                   !2, $5
    7     7        INIT_FCALL_BY_NAME                                       'dump'
          8        SEND_VAR_EX                                              !2
          9        DO_FCALL                                      0          
    8    10        INIT_FCALL                                               'explode'
         11        SEND_VAL                                                 '+'
         12        SEND_VAR                                                 !2
         13        DO_ICALL                                         $8      
         14        ASSIGN                                                   !3, $8
    9    15        IS_NOT_IDENTICAL                                         !0, !2
         16      > JMPZ                                                     ~10, ->43
   10    17    >   INIT_FCALL                                               'array_combine'
         18        SEND_VAR                                                 !3
         19        SEND_VAR                                                 !3
         20        DO_ICALL                                         $11     
         21        ASSIGN                                                   !3, $11
   11    22        INIT_FCALL                                               'array_map'
         23        SEND_VAL                                                 'trim'
         24        INIT_FCALL                                               'array_flip'
         25        INIT_FCALL                                               'array_map'
         26        SEND_VAL                                                 'trim'
         27        SEND_VAR                                                 !1
         28        DO_ICALL                                         $13     
         29        SEND_VAR                                                 $13
         30        DO_ICALL                                         $14     
         31        SEND_VAR                                                 $14
         32        DO_ICALL                                         $15     
         33        ASSIGN                                                   !4, $15
   12    34        INIT_FCALL                                               'array_replace'
         35        SEND_VAR                                                 !3
         36        INIT_FCALL                                               'array_intersect_key'
         37        SEND_VAR                                                 !4
         38        SEND_VAR                                                 !3
         39        DO_ICALL                                         $17     
         40        SEND_VAR                                                 $17
         41        DO_ICALL                                         $18     
         42        ASSIGN                                                   !3, $18
   14    43    >   INIT_FCALL                                               'array_values'
         44        SEND_VAR                                                 !3
         45        DO_ICALL                                         $20     
         46      > RETURN                                                   $20
   15    47*     > RETURN                                                   null

End of function f

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
181.81 ms | 1402 KiB | 36 Q