3v4l.org

run code in 500+ PHP versions simultaneously
<?php $str1 = ["AD-2018-34567-234","10256","1234567890-rfwet043-123455-cd1234-sdf"]; $str2 = ["cd 34567","cd 10256","4edgs-cd12340e-3ed"]; foreach($str1 as $key => $str){ $find = $str2[$key]; $l = strlen($find); $match = false; for($i=0; $i<=($l-5);$i++){ // loop the find string //echo $str . " " . substr($find,$i, 5) . "\n"; // debug if(strpos($str, substr($find,$i, 5)) !== false) { // take five characters at the time and stros them $match = true; break; } } if($match){ echo "match\n"; }else{ echo "no match\n"; } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 28
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 28
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
2 jumps found. (Code = 44) Position 1 = 23, Position 2 = 12
Branch analysis from position: 23
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 26
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 19
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
Branch analysis from position: 19
2 jumps found. (Code = 44) Position 1 = 23, Position 2 = 12
Branch analysis from position: 23
Branch analysis from position: 12
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
filename:       /in/unp0D
function name:  (null)
number of ops:  30
compiled vars:  !0 = $str1, !1 = $str2, !2 = $str, !3 = $key, !4 = $find, !5 = $l, !6 = $match, !7 = $i
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
    4     1        ASSIGN                                                       !1, <array>
    6     2      > FE_RESET_R                                           $10     !0, ->28
          3    > > FE_FETCH_R                                           ~11     $10, !2, ->28
          4    >   ASSIGN                                                       !3, ~11
    7     5        FETCH_DIM_R                                          ~13     !1, !3
          6        ASSIGN                                                       !4, ~13
    8     7        STRLEN                                               ~15     !4
          8        ASSIGN                                                       !5, ~15
    9     9        ASSIGN                                                       !6, <false>
   10    10        ASSIGN                                                       !7, 0
         11      > JMP                                                          ->20
   12    12    >   FRAMELESS_ICALL_3                substr              ~19     !4, !7
         13        OP_DATA                                                      5
         14        FRAMELESS_ICALL_2                strpos              ~20     !2, ~19
         15        TYPE_CHECK                                      1018          ~20
         16      > JMPZ                                                         ~21, ->19
   13    17    >   ASSIGN                                                       !6, <true>
   14    18      > JMP                                                          ->23
   10    19    >   PRE_INC                                                      !7
         20    >   SUB                                                  ~24     !5, 5
         21        IS_SMALLER_OR_EQUAL                                          !7, ~24
         22      > JMPNZ                                                        ~25, ->12
   17    23    > > JMPZ                                                         !6, ->26
   18    24    >   ECHO                                                         'match%0A'
   17    25      > JMP                                                          ->27
   20    26    >   ECHO                                                         'no+match%0A'
    6    27    > > JMP                                                          ->3
         28    >   FE_FREE                                                      $10
   22    29      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
172.47 ms | 2528 KiB | 13 Q