3v4l.org

run code in 300+ PHP versions simultaneously
<?php function wordScore($word){ $map = '^^abcdefghijklmnopqrstuvwxyz1234567890'; return array_reduce(str_split($word), function($score, $letter) use ($map) { if (!$score) return stripos($map, $letter); return $score + stripos($map, $letter); }); } echo wordScore('suzuki') . "\n"; echo wordScore('sports'); exit;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 79) Position 1 = -2
filename:       /in/3EQJj
function name:  (null)
number of ops:  11
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   INIT_FCALL                                               'wordscore'
          1        SEND_VAL                                                 'suzuki'
          2        DO_FCALL                                      0  $0      
          3        CONCAT                                           ~1      $0, '%0A'
          4        ECHO                                                     ~1
   13     5        INIT_FCALL                                               'wordscore'
          6        SEND_VAL                                                 'sports'
          7        DO_FCALL                                      0  $2      
          8        ECHO                                                     $2
   14     9      > EXIT                                                     
         10*     > RETURN                                                   1

Function wordscore:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3EQJj
function name:  wordScore
number of ops:  13
compiled vars:  !0 = $word, !1 = $map
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
    5     1        ASSIGN                                                   !1, '%5E%5Eabcdefghijklmnopqrstuvwxyz1234567890'
    6     2        INIT_FCALL                                               'array_reduce'
          3        INIT_FCALL                                               'str_split'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $3      
          6        SEND_VAR                                                 $3
          7        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F3EQJj%3A6%240'
          8        BIND_LEXICAL                                             ~4, !1
    9     9        SEND_VAL                                                 ~4
         10        DO_ICALL                                         $5      
         11      > RETURN                                                   $5
   10    12*     > RETURN                                                   null

End of function wordscore

Function %00%7Bclosure%7D%2Fin%2F3EQJj%3A6%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 10
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3EQJj
function name:  {closure}
number of ops:  17
compiled vars:  !0 = $score, !1 = $letter, !2 = $map
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
    7     3        BOOL_NOT                                         ~3      !0
          4      > JMPZ                                                     ~3, ->10
          5    >   INIT_FCALL                                               'stripos'
          6        SEND_VAR                                                 !2
          7        SEND_VAR                                                 !1
          8        DO_ICALL                                         $4      
          9      > RETURN                                                   $4
    8    10    >   INIT_FCALL                                               'stripos'
         11        SEND_VAR                                                 !2
         12        SEND_VAR                                                 !1
         13        DO_ICALL                                         $5      
         14        ADD                                              ~6      !0, $5
         15      > RETURN                                                   ~6
    9    16*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F3EQJj%3A6%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.15 ms | 1394 KiB | 21 Q