3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = ["W", "L", "W", "W"]; $arr = array_reverse($arr); $last = array_shift($arr); //Shift takes out the first element, but we reversed it, so it's last. $counter = 1; foreach ($arr as $result) { if ($result != $last) break; $counter++; } echo $counter;
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 11, Position 2 = 17
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 17
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 15
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 17
Branch analysis from position: 17
filename:       /in/LZ4Bq
function name:  (null)
number of ops:  20
compiled vars:  !0 = $arr, !1 = $last, !2 = $counter, !3 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        INIT_FCALL                                               'array_reverse'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $5      
          4        ASSIGN                                                   !0, $5
    5     5        INIT_FCALL                                               'array_shift'
          6        SEND_REF                                                 !0
          7        DO_ICALL                                         $7      
          8        ASSIGN                                                   !1, $7
    6     9        ASSIGN                                                   !2, 1
    7    10      > FE_RESET_R                                       $10     !0, ->17
         11    > > FE_FETCH_R                                               $10, !3, ->17
    8    12    >   IS_NOT_EQUAL                                             !3, !1
         13      > JMPZ                                                     ~11, ->15
         14    > > JMP                                                      ->17
    9    15    >   PRE_INC                                                  !2
    7    16      > JMP                                                      ->11
         17    >   FE_FREE                                                  $10
   12    18        ECHO                                                     !2
         19      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.21 ms | 1395 KiB | 17 Q