3v4l.org

run code in 300+ PHP versions simultaneously
<?php function longest_palendrome($string) { $current = $longest = ''; foreach (str_split(strrev($string)) as $char) { if (strstr($string, $current . $char)) { $current .= $char; } elseif (!empty($current) && strlen($current) > strlen($longest)) { $longest = $current; $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/iqLeV
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 = 17, Position 2 = 19
Branch analysis from position: 17
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: 19
2 jumps found. (Code = 46) Position 1 = 22, Position 2 = 26
Branch analysis from position: 22
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 29
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 29
Branch analysis from position: 26
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
filename:       /in/iqLeV
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    >   INIT_FCALL                                               'strstr'
         12        SEND_VAR                                                 !0
         13        CONCAT                                           ~9      !1, !3
         14        SEND_VAL                                                 ~9
         15        DO_ICALL                                         $10     
         16      > JMPZ                                                     $10, ->19
    7    17    >   ASSIGN_OP                                     8          !1, !3
         18      > JMP                                                      ->29
    8    19    >   ISSET_ISEMPTY_CV                                 ~12     !1
         20        BOOL_NOT                                         ~13     ~12
         21      > JMPZ_EX                                          ~13     ~13, ->26
         22    >   STRLEN                                           ~14     !1
         23        STRLEN                                           ~15     !2
         24        IS_SMALLER                                       ~16     ~15, ~14
         25        BOOL                                             ~13     ~16
         26    > > JMPZ                                                     ~13, ->29
    9    27    >   ASSIGN                                                   !2, !1
   10    28        ASSIGN                                                   !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:
157.6 ms | 1403 KiB | 20 Q