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) $score = 2; return $score | pow(stripos($map, $letter), 2); }); } echo wordScore('whisky'); exit;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 79) Position 1 = -2
filename:       /in/00hf8
function name:  (null)
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   INIT_FCALL                                               'wordscore'
          1        SEND_VAL                                                 'whisky'
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
   13     4      > EXIT                                                     
          5*     > RETURN                                                   1

Function wordscore:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/00hf8
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%2F00hf8%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%2F00hf8%3A6%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 6
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
filename:       /in/00hf8
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, ->6
          5    >   ASSIGN                                                   !0, 2
    8     6    >   INIT_FCALL                                               'pow'
          7        INIT_FCALL                                               'stripos'
          8        SEND_VAR                                                 !2
          9        SEND_VAR                                                 !1
         10        DO_ICALL                                         $5      
         11        SEND_VAR                                                 $5
         12        SEND_VAL                                                 2
         13        DO_ICALL                                         $6      
         14        BW_OR                                            ~7      !0, $6
         15      > RETURN                                                   ~7
    9    16*     > RETURN                                                   null

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

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.07 ms | 1407 KiB | 22 Q