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 pow(stripos($map, $letter), 2); return $score | pow(stripos($map, $letter), 2); }); } echo wordScore('london') . "\n"; echo wordScore('sports'); exit;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 79) Position 1 = -2
filename:       /in/YAf31
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                                                 'london'
          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/YAf31
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%2FYAf31%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%2FYAf31%3A6%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 14
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YAf31
function name:  {closure}
number of ops:  25
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, ->14
          5    >   INIT_FCALL                                               'pow'
          6        INIT_FCALL                                               'stripos'
          7        SEND_VAR                                                 !2
          8        SEND_VAR                                                 !1
          9        DO_ICALL                                         $4      
         10        SEND_VAR                                                 $4
         11        SEND_VAL                                                 2
         12        DO_ICALL                                         $5      
         13      > RETURN                                                   $5
    8    14    >   INIT_FCALL                                               'pow'
         15        INIT_FCALL                                               'stripos'
         16        SEND_VAR                                                 !2
         17        SEND_VAR                                                 !1
         18        DO_ICALL                                         $6      
         19        SEND_VAR                                                 $6
         20        SEND_VAL                                                 2
         21        DO_ICALL                                         $7      
         22        BW_OR                                            ~8      !0, $7
         23      > RETURN                                                   ~8
    9    24*     > RETURN                                                   null

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

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
180.99 ms | 1403 KiB | 23 Q