3v4l.org

run code in 300+ PHP versions simultaneously
<?php $names = array('Anderson','Beresford','Donovan','Emerson','Graham'); $alphabet = array(); $previous_letter = ''; foreach($names as $value) { if($value[0] != $previous_letter) { $alphabet[] = $previous_letter = $value[0]; } } print_r($alphabet); ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 13
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 13
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 12
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 12
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
filename:       /in/VT0Rt
function name:  (null)
number of ops:  18
compiled vars:  !0 = $names, !1 = $alphabet, !2 = $previous_letter, !3 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    5     1        ASSIGN                                                   !1, <array>
    6     2        ASSIGN                                                   !2, ''
    8     3      > FE_RESET_R                                       $7      !0, ->13
          4    > > FE_FETCH_R                                               $7, !3, ->13
    9     5    >   FETCH_DIM_R                                      ~8      !3, 0
          6        IS_NOT_EQUAL                                             !2, ~8
          7      > JMPZ                                                     ~9, ->12
   10     8    >   FETCH_DIM_R                                      ~11     !3, 0
          9        ASSIGN                                           ~12     !2, ~11
         10        ASSIGN_DIM                                               !1
         11        OP_DATA                                                  ~12
    8    12    > > JMP                                                      ->4
         13    >   FE_FREE                                                  $7
   14    14        INIT_FCALL                                               'print_r'
         15        SEND_VAR                                                 !1
         16        DO_ICALL                                                 
   16    17      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.01 ms | 1395 KiB | 15 Q