3v4l.org

run code in 300+ PHP versions simultaneously
<?php $word1 = 'abcdefghijkl'; $word2 = 'acgikluuo'; $expected = 6; function countMatchingChars($word1, $word2) { $matching = 0; foreach(str_split($word1) as $char) { if(strpos($word2, $char) !== false) { $matching++; } } return $matching; } $matchingChars = countMatchingChars($word1, $word2); assert($matchingChars === $expected);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7ogrE
function name:  (null)
number of ops:  15
compiled vars:  !0 = $word1, !1 = $word2, !2 = $expected, !3 = $matchingChars
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'abcdefghijkl'
    4     1        ASSIGN                                                   !1, 'acgikluuo'
    5     2        ASSIGN                                                   !2, 6
   18     3        INIT_FCALL                                               'countmatchingchars'
          4        SEND_VAR                                                 !0
          5        SEND_VAR                                                 !1
          6        DO_FCALL                                      0  $7      
          7        ASSIGN                                                   !3, $7
   20     8        ASSERT_CHECK                                             
          9        INIT_FCALL                                               'assert'
         10        IS_IDENTICAL                                     ~9      !3, !2
         11        SEND_VAL                                                 ~9
         12        SEND_VAL                                                 'assert%28%24matchingChars+%3D%3D%3D+%24expected%29'
         13        DO_ICALL                                                 
         14      > RETURN                                                   1

Function countmatchingchars:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 16
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 16
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 15
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 15
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
filename:       /in/7ogrE
function name:  countMatchingChars
number of ops:  19
compiled vars:  !0 = $word1, !1 = $word2, !2 = $matching, !3 = $char
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    8     2        ASSIGN                                                   !2, 0
    9     3        INIT_FCALL                                               'str_split'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $5      
          6      > FE_RESET_R                                       $6      $5, ->16
          7    > > FE_FETCH_R                                               $6, !3, ->16
   10     8    >   INIT_FCALL                                               'strpos'
          9        SEND_VAR                                                 !1
         10        SEND_VAR                                                 !3
         11        DO_ICALL                                         $7      
         12        TYPE_CHECK                                  1018          $7
         13      > JMPZ                                                     ~8, ->15
   11    14    >   PRE_INC                                                  !2
    9    15    > > JMP                                                      ->7
         16    >   FE_FREE                                                  $6
   15    17      > RETURN                                                   !2
   16    18*     > RETURN                                                   null

End of function countmatchingchars

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
280.16 ms | 1020 KiB | 17 Q