3v4l.org

run code in 300+ PHP versions simultaneously
<?php function longest_palendrome($string) { $words = split(' ', $string); $longest = ''; foreach ($words as $word) { $letters = $reversed = split($word); array_reverse($reversed); if ($letters === join($reversed) && strlen($word) > strlen($longest)) { $longest = $word; } } return $word; } echo longest_palendrome("i ama racecar");
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4QHue
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     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 = 8, Position 2 = 29
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 29
Branch analysis from position: 9
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 = 28
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 28
Branch analysis from position: 26
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
filename:       /in/4QHue
function name:  longest_palendrome
number of ops:  32
compiled vars:  !0 = $string, !1 = $words, !2 = $longest, !3 = $word, !4 = $letters, !5 = $reversed
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    4     1        INIT_FCALL_BY_NAME                                       'split'
          2        SEND_VAL_EX                                              '+'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0  $6      
          5        ASSIGN                                                   !1, $6
    5     6        ASSIGN                                                   !2, ''
    6     7      > FE_RESET_R                                       $9      !1, ->29
          8    > > FE_FETCH_R                                               $9, !3, ->29
    7     9    >   INIT_FCALL_BY_NAME                                       'split'
         10        SEND_VAR_EX                                              !3
         11        DO_FCALL                                      0  $10     
         12        ASSIGN                                           ~11     !5, $10
         13        ASSIGN                                                   !4, ~11
    8    14        INIT_FCALL                                               'array_reverse'
         15        SEND_VAR                                                 !5
         16        DO_ICALL                                                 
    9    17        INIT_FCALL                                               'join'
         18        SEND_VAR                                                 !5
         19        DO_ICALL                                         $14     
         20        IS_IDENTICAL                                     ~15     !4, $14
         21      > JMPZ_EX                                          ~15     ~15, ->26
         22    >   STRLEN                                           ~16     !3
         23        STRLEN                                           ~17     !2
         24        IS_SMALLER                                       ~18     ~17, ~16
         25        BOOL                                             ~15     ~18
         26    > > JMPZ                                                     ~15, ->28
   10    27    >   ASSIGN                                                   !2, !3
    6    28    > > JMP                                                      ->8
         29    >   FE_FREE                                                  $9
   14    30      > RETURN                                                   !3
   15    31*     > RETURN                                                   null

End of function longest_palendrome

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.51 ms | 1403 KiB | 18 Q