3v4l.org

run code in 300+ PHP versions simultaneously
<?php $sequences = ["6", "66", "67", "68", "69", "697", "698", "699"]; $data = ["69212345", "6209876544", "697986546"]; function get_longest_subsequence_element(array $sequences, $str){ $longestSequence = ""; for($strPosition = 0, $strPositionEnd = strlen($str) - 1; $strPosition < $strPositionEnd; $strPosition++){ for($strLength = 1, $strLengthEnd = strlen($str) - $strPosition; $strLength < $strLengthEnd; $strLength++){ if(in_array($sequence = substr($str, $strPosition, $strLength), $sequences) && $strLength > strlen($longestSequence)) $longestSequence = $sequence; } } return $longestSequence; } foreach($data as $str) echo get_longest_subsequence_element($sequences, $str) . "<br>"; ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 11
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 11
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
filename:       /in/fc9j7
function name:  (null)
number of ops:  13
compiled vars:  !0 = $sequences, !1 = $data, !2 = $str
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        ASSIGN                                                   !1, <array>
   27     2      > FE_RESET_R                                       $5      !1, ->11
          3    > > FE_FETCH_R                                               $5, !2, ->11
   28     4    >   INIT_FCALL                                               'get_longest_subsequence_element'
          5        SEND_VAR                                                 !0
          6        SEND_VAR                                                 !2
          7        DO_FCALL                                      0  $6      
          8        CONCAT                                           ~7      $6, '%3Cbr%3E'
          9        ECHO                                                     ~7
   27    10      > JMP                                                      ->3
         11    >   FE_FREE                                                  $5
   33    12      > RETURN                                                   1

Function get_longest_subsequence_element:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
2 jumps found. (Code = 44) Position 1 = 35, Position 2 = 8
Branch analysis from position: 35
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
2 jumps found. (Code = 44) Position 1 = 32, Position 2 = 13
Branch analysis from position: 32
2 jumps found. (Code = 44) Position 1 = 35, Position 2 = 8
Branch analysis from position: 35
Branch analysis from position: 8
Branch analysis from position: 13
2 jumps found. (Code = 46) Position 1 = 24, Position 2 = 27
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 29
Branch analysis from position: 28
2 jumps found. (Code = 44) Position 1 = 32, Position 2 = 13
Branch analysis from position: 32
Branch analysis from position: 13
Branch analysis from position: 29
Branch analysis from position: 27
filename:       /in/fc9j7
function name:  get_longest_subsequence_element
number of ops:  37
compiled vars:  !0 = $sequences, !1 = $str, !2 = $longestSequence, !3 = $strPosition, !4 = $strPositionEnd, !5 = $strLength, !6 = $strLengthEnd, !7 = $sequence
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    9     2        ASSIGN                                                   !2, ''
   11     3        ASSIGN                                                   !3, 0
          4        STRLEN                                           ~10     !1
          5        SUB                                              ~11     ~10, 1
          6        ASSIGN                                                   !4, ~11
          7      > JMP                                                      ->33
   13     8    >   ASSIGN                                                   !5, 1
          9        STRLEN                                           ~14     !1
         10        SUB                                              ~15     ~14, !3
         11        ASSIGN                                                   !6, ~15
         12      > JMP                                                      ->30
   15    13    >   INIT_FCALL                                               'in_array'
         14        INIT_FCALL                                               'substr'
         15        SEND_VAR                                                 !1
         16        SEND_VAR                                                 !3
         17        SEND_VAR                                                 !5
         18        DO_ICALL                                         $17     
         19        ASSIGN                                           ~18     !7, $17
         20        SEND_VAL                                                 ~18
         21        SEND_VAR                                                 !0
         22        DO_ICALL                                         $19     
         23      > JMPZ_EX                                          ~20     $19, ->27
         24    >   STRLEN                                           ~21     !2
         25        IS_SMALLER                                       ~22     ~21, !5
         26        BOOL                                             ~20     ~22
         27    > > JMPZ                                                     ~20, ->29
   16    28    >   ASSIGN                                                   !2, !7
   13    29    >   PRE_INC                                                  !5
         30    >   IS_SMALLER                                               !5, !6
         31      > JMPNZ                                                    ~25, ->13
   11    32    >   PRE_INC                                                  !3
         33    >   IS_SMALLER                                               !3, !4
         34      > JMPNZ                                                    ~27, ->8
   22    35    > > RETURN                                                   !2
   24    36*     > RETURN                                                   null

End of function get_longest_subsequence_element

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
170.17 ms | 1403 KiB | 18 Q