3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=1); function summary(array $row): int { $sum = 0; foreach(['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'] as $char) { $char = mb_strtoupper($char); $status = (string)($row['Status_' . $char] ?? ''); $userPower = (int)($row['Pow_Uzyt_' . $char] ?? 0); if ($status === $char) { $sum += $userPower; } } return $sum; } $array = [ 'Status_A' => 'A', 'Pow_Uzyt_A' => 10, 'Status_B' => 'B', 'Pow_Uzyt_B' => 5, 'Status_C' => '', 'Pow_Uzyt_C' => 100, ]; echo summary($array);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4MkRf
function name:  (null)
number of ops:  6
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   ASSIGN                                                   !0, <array>
   31     1        INIT_FCALL                                               'summary'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0  $2      
          4        ECHO                                                     $2
          5      > RETURN                                                   1

Function summary:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 24
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 24
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 23
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 23
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
filename:       /in/4MkRf
function name:  summary
number of ops:  29
compiled vars:  !0 = $row, !1 = $sum, !2 = $char, !3 = $status, !4 = $userPower
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    7     1        ASSIGN                                                   !1, 0
    9     2      > FE_RESET_R                                       $6      <array>, ->24
          3    > > FE_FETCH_R                                               $6, !2, ->24
   10     4    >   INIT_FCALL                                               'mb_strtoupper'
          5        SEND_VAR                                                 !2
          6        DO_ICALL                                         $7      
          7        ASSIGN                                                   !2, $7
   11     8        CONCAT                                           ~9      'Status_', !2
          9        FETCH_DIM_IS                                     ~10     !0, ~9
         10        COALESCE                                         ~11     ~10
         11        QM_ASSIGN                                        ~11     ''
         12        CAST                                          6  ~12     ~11
         13        ASSIGN                                                   !3, ~12
   12    14        CONCAT                                           ~14     'Pow_Uzyt_', !2
         15        FETCH_DIM_IS                                     ~15     !0, ~14
         16        COALESCE                                         ~16     ~15
         17        QM_ASSIGN                                        ~16     0
         18        CAST                                          4  ~17     ~16
         19        ASSIGN                                                   !4, ~17
   14    20        IS_IDENTICAL                                             !3, !2
         21      > JMPZ                                                     ~19, ->23
   15    22    >   ASSIGN_OP                                     1          !1, !4
    9    23    > > JMP                                                      ->3
         24    >   FE_FREE                                                  $6
   19    25        VERIFY_RETURN_TYPE                                       !1
         26      > RETURN                                                   !1
   20    27*       VERIFY_RETURN_TYPE                                       
         28*     > RETURN                                                   null

End of function summary

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
135.69 ms | 1005 KiB | 15 Q