3v4l.org

run code in 300+ PHP versions simultaneously
<?php function longest_palendrome($string) { $words = explode(' ', $string); $longest = ''; foreach ($words as $word) { $letters = $reversed = explode('', $word); array_reverse($reversed); if ($letters === implode('', $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/jJuJX
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 = 31
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 31
Branch analysis from position: 9
2 jumps found. (Code = 46) Position 1 = 24, Position 2 = 28
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 29, Position 2 = 30
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 30
Branch analysis from position: 28
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
filename:       /in/jJuJX
function name:  longest_palendrome
number of ops:  34
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                                               'explode'
          2        SEND_VAL                                                 '+'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $6      
          5        ASSIGN                                                   !1, $6
    5     6        ASSIGN                                                   !2, ''
    6     7      > FE_RESET_R                                       $9      !1, ->31
          8    > > FE_FETCH_R                                               $9, !3, ->31
    7     9    >   INIT_FCALL                                               'explode'
         10        SEND_VAL                                                 ''
         11        SEND_VAR                                                 !3
         12        DO_ICALL                                         $10     
         13        ASSIGN                                           ~11     !5, $10
         14        ASSIGN                                                   !4, ~11
    8    15        INIT_FCALL                                               'array_reverse'
         16        SEND_VAR                                                 !5
         17        DO_ICALL                                                 
    9    18        INIT_FCALL                                               'implode'
         19        SEND_VAL                                                 ''
         20        SEND_VAR                                                 !5
         21        DO_ICALL                                         $14     
         22        IS_IDENTICAL                                     ~15     !4, $14
         23      > JMPZ_EX                                          ~15     ~15, ->28
         24    >   STRLEN                                           ~16     !3
         25        STRLEN                                           ~17     !2
         26        IS_SMALLER                                       ~18     ~17, ~16
         27        BOOL                                             ~15     ~18
         28    > > JMPZ                                                     ~15, ->30
   10    29    >   ASSIGN                                                   !2, !3
    6    30    > > JMP                                                      ->8
         31    >   FE_FREE                                                  $9
   14    32      > RETURN                                                   !3
   15    33*     > RETURN                                                   null

End of function longest_palendrome

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.41 ms | 1403 KiB | 20 Q