3v4l.org

run code in 300+ PHP versions simultaneously
<?php $input = "9121221212119"; $calculate = function($input) { $sum = 0; $previousChar = $input[strlen($input) - 1]; foreach(str_split($input) as $char) { if ($char === $previousChar) { $sum += (int)$char; } $previousChar = $char; } return $sum; }; var_dump($calculate($input));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TKlvs
function name:  (null)
number of ops:  10
compiled vars:  !0 = $input, !1 = $calculate
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '9121221212119'
    6     1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FTKlvs%3A6%240'
          2        ASSIGN                                                   !1, ~3
   18     3        INIT_FCALL                                               'var_dump'
          4        INIT_DYNAMIC_CALL                                        !1
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0  $5      
          7        SEND_VAR                                                 $5
          8        DO_ICALL                                                 
          9      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FTKlvs%3A6%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 17
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 17
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 15
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 15
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
filename:       /in/TKlvs
function name:  {closure}
number of ops:  20
compiled vars:  !0 = $input, !1 = $sum, !2 = $previousChar, !3 = $char
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    7     1        ASSIGN                                                   !1, 0
    8     2        STRLEN                                           ~5      !0
          3        SUB                                              ~6      ~5, 1
          4        FETCH_DIM_R                                      ~7      !0, ~6
          5        ASSIGN                                                   !2, ~7
    9     6        INIT_FCALL                                               'str_split'
          7        SEND_VAR                                                 !0
          8        DO_ICALL                                         $9      
          9      > FE_RESET_R                                       $10     $9, ->17
         10    > > FE_FETCH_R                                               $10, !3, ->17
   10    11    >   IS_IDENTICAL                                             !3, !2
         12      > JMPZ                                                     ~11, ->15
   11    13    >   CAST                                          4  ~12     !3
         14        ASSIGN_OP                                     1          !1, ~12
   13    15    >   ASSIGN                                                   !2, !3
    9    16      > JMP                                                      ->10
         17    >   FE_FREE                                                  $10
   15    18      > RETURN                                                   !1
   16    19*     > RETURN                                                   null

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

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
178.31 ms | 1396 KiB | 17 Q