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

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

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.16 ms | 1402 KiB | 23 Q