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) { echo stripos($map, $letter) . "\n"; if (!$score) return pow(stripos($map, $letter), 2); return $score | pow(stripos($map, $letter), 2); }); } echo wordScore('squirt') . "\n"; echo wordScore('sports'); exit;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 79) Position 1 = -2
filename:       /in/Tl17C
function name:  (null)
number of ops:  11
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   INIT_FCALL                                               'wordscore'
          1        SEND_VAL                                                 'squirt'
          2        DO_FCALL                                      0  $0      
          3        CONCAT                                           ~1      $0, '%0A'
          4        ECHO                                                     ~1
   14     5        INIT_FCALL                                               'wordscore'
          6        SEND_VAL                                                 'sports'
          7        DO_FCALL                                      0  $2      
          8        ECHO                                                     $2
   15     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/Tl17C
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%2FTl17C%3A6%240'
          8        BIND_LEXICAL                                             ~4, !1
   10     9        SEND_VAL                                                 ~4
         10        DO_ICALL                                         $5      
         11      > RETURN                                                   $5
   11    12*     > RETURN                                                   null

End of function wordscore

Function %00%7Bclosure%7D%2Fin%2FTl17C%3A6%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 20
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Tl17C
function name:  {closure}
number of ops:  31
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        INIT_FCALL                                               'stripos'
          4        SEND_VAR                                                 !2
          5        SEND_VAR                                                 !1
          6        DO_ICALL                                         $3      
          7        CONCAT                                           ~4      $3, '%0A'
          8        ECHO                                                     ~4
    8     9        BOOL_NOT                                         ~5      !0
         10      > JMPZ                                                     ~5, ->20
         11    >   INIT_FCALL                                               'pow'
         12        INIT_FCALL                                               'stripos'
         13        SEND_VAR                                                 !2
         14        SEND_VAR                                                 !1
         15        DO_ICALL                                         $6      
         16        SEND_VAR                                                 $6
         17        SEND_VAL                                                 2
         18        DO_ICALL                                         $7      
         19      > RETURN                                                   $7
    9    20    >   INIT_FCALL                                               'pow'
         21        INIT_FCALL                                               'stripos'
         22        SEND_VAR                                                 !2
         23        SEND_VAR                                                 !1
         24        DO_ICALL                                         $8      
         25        SEND_VAR                                                 $8
         26        SEND_VAL                                                 2
         27        DO_ICALL                                         $9      
         28        BW_OR                                            ~10     !0, $9
         29      > RETURN                                                   ~10
   10    30*     > RETURN                                                   null

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

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.97 ms | 1407 KiB | 23 Q