3v4l.org

run code in 300+ PHP versions simultaneously
<?php $start = microtime(true); function censorWord($word, $censor) { if(strpos($word, $censor)) { return preg_replace("/$censor/",'*', $word, 1); } } $word_list = ['php','javascript']; $data = "Javascript and php are awesome!"; $words = explode(" ", $data); // pass each word by reference so it can be modified inside our array foreach($words as &$word) { if(in_array(strtolower($word), $word_list)) { // this just passes the second letter of the word // as the $censor argument $word = censorWord($word, $word[1]); } } echo implode(" ", $words); // returns J*vascript and p*p are awesome! $end = (microtime(true)); echo '<br />'; echo $end - $start;
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 125) Position 1 = 12, Position 2 = 28
Branch analysis from position: 12
2 jumps found. (Code = 126) Position 1 = 13, Position 2 = 28
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 27
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 27
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
filename:       /in/2SIW0
function name:  (null)
number of ops:  42
compiled vars:  !0 = $start, !1 = $word_list, !2 = $data, !3 = $words, !4 = $word, !5 = $end
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   INIT_FCALL                                               'microtime'
          1        SEND_VAL                                                 <true>
          2        DO_ICALL                                         $6      
          3        ASSIGN                                                   !0, $6
    9     4        ASSIGN                                                   !1, <array>
   10     5        ASSIGN                                                   !2, 'Javascript+and+php+are+awesome%21'
   11     6        INIT_FCALL                                               'explode'
          7        SEND_VAL                                                 '+'
          8        SEND_VAR                                                 !2
          9        DO_ICALL                                         $10     
         10        ASSIGN                                                   !3, $10
   13    11      > FE_RESET_RW                                      $12     !3, ->28
         12    > > FE_FETCH_RW                                              $12, !4, ->28
   14    13    >   INIT_FCALL                                               'in_array'
         14        INIT_FCALL                                               'strtolower'
         15        SEND_VAR                                                 !4
         16        DO_ICALL                                         $13     
         17        SEND_VAR                                                 $13
         18        SEND_VAR                                                 !1
         19        DO_ICALL                                         $14     
         20      > JMPZ                                                     $14, ->27
   17    21    >   INIT_FCALL                                               'censorword'
         22        SEND_VAR                                                 !4
         23        FETCH_DIM_R                                      ~15     !4, 1
         24        SEND_VAL                                                 ~15
         25        DO_FCALL                                      0  $16     
         26        ASSIGN                                                   !4, $16
   13    27    > > JMP                                                      ->12
         28    >   FE_FREE                                                  $12
   20    29        INIT_FCALL                                               'implode'
         30        SEND_VAL                                                 '+'
         31        SEND_VAR                                                 !3
         32        DO_ICALL                                         $18     
         33        ECHO                                                     $18
   21    34        INIT_FCALL                                               'microtime'
         35        SEND_VAL                                                 <true>
         36        DO_ICALL                                         $19     
         37        ASSIGN                                                   !5, $19
   22    38        ECHO                                                     '%3Cbr+%2F%3E'
   23    39        SUB                                              ~21     !5, !0
         40        ECHO                                                     ~21
         41      > RETURN                                                   1

Function censorword:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 17
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2SIW0
function name:  censorWord
number of ops:  18
compiled vars:  !0 = $word, !1 = $censor
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2        INIT_FCALL                                               'strpos'
          3        SEND_VAR                                                 !0
          4        SEND_VAR                                                 !1
          5        DO_ICALL                                         $2      
          6      > JMPZ                                                     $2, ->17
    5     7    >   INIT_FCALL                                               'preg_replace'
          8        ROPE_INIT                                     3  ~4      '%2F'
          9        ROPE_ADD                                      1  ~4      ~4, !1
         10        ROPE_END                                      2  ~3      ~4, '%2F'
         11        SEND_VAL                                                 ~3
         12        SEND_VAL                                                 '%2A'
         13        SEND_VAR                                                 !0
         14        SEND_VAL                                                 1
         15        DO_ICALL                                         $6      
         16      > RETURN                                                   $6
    7    17    > > RETURN                                                   null

End of function censorword

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.67 ms | 1403 KiB | 28 Q