3v4l.org

run code in 300+ PHP versions simultaneously
<?php function longest_palendrome($string) { $current = $longest = ''; foreach (str_split(strrev($string)) as $char) { echo $char; if (strstr($current . $char, $string)) { $current .= $char; } elseif (!empty($current) && strlen($current) > strlen($longest)) { $longest = $current; } } return $longest; } echo longest_palendrome("i ama racecar");
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GPgme
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   INIT_FCALL                                               'longest_palendrome'
          1        SEND_VAL                                                 'i+ama+racecar'
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
          4      > RETURN                                                   1

Function longest_palendrome:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 30
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 30
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 20
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 20
2 jumps found. (Code = 46) Position 1 = 23, Position 2 = 27
Branch analysis from position: 23
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 29
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 29
Branch analysis from position: 27
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
filename:       /in/GPgme
function name:  longest_palendrome
number of ops:  33
compiled vars:  !0 = $string, !1 = $current, !2 = $longest, !3 = $char
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    4     1        ASSIGN                                           ~4      !2, ''
          2        ASSIGN                                                   !1, ~4
    5     3        INIT_FCALL                                               'str_split'
          4        INIT_FCALL                                               'strrev'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $6      
          7        SEND_VAR                                                 $6
          8        DO_ICALL                                         $7      
          9      > FE_RESET_R                                       $8      $7, ->30
         10    > > FE_FETCH_R                                               $8, !3, ->30
    6    11    >   ECHO                                                     !3
    7    12        INIT_FCALL                                               'strstr'
         13        CONCAT                                           ~9      !1, !3
         14        SEND_VAL                                                 ~9
         15        SEND_VAR                                                 !0
         16        DO_ICALL                                         $10     
         17      > JMPZ                                                     $10, ->20
    8    18    >   ASSIGN_OP                                     8          !1, !3
         19      > JMP                                                      ->29
    9    20    >   ISSET_ISEMPTY_CV                                 ~12     !1
         21        BOOL_NOT                                         ~13     ~12
         22      > JMPZ_EX                                          ~13     ~13, ->27
         23    >   STRLEN                                           ~14     !1
         24        STRLEN                                           ~15     !2
         25        IS_SMALLER                                       ~16     ~15, ~14
         26        BOOL                                             ~13     ~16
         27    > > JMPZ                                                     ~13, ->29
   10    28    >   ASSIGN                                                   !2, !1
    5    29    > > JMP                                                      ->10
         30    >   FE_FREE                                                  $8
   13    31      > RETURN                                                   !2
   14    32*     > RETURN                                                   null

End of function longest_palendrome

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
178.16 ms | 1403 KiB | 20 Q