3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = Array ('a','b','a','a','a','c','c','b','b','a','a','a','a'); $result = []; $count = 0; $current = $array[0]; for ($i = 0; $i < count($array); $i++) { if ($array[$i] == $current) { $count++; } else { $result[] = array($current, $count); $count = 1; } $current = $array[$i]; } $result[] = array($current, $count); print_r($result);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
2 jumps found. (Code = 44) Position 1 = 23, Position 2 = 7
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 12
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
2 jumps found. (Code = 44) Position 1 = 23, Position 2 = 7
Branch analysis from position: 23
Branch analysis from position: 7
Branch analysis from position: 12
2 jumps found. (Code = 44) Position 1 = 23, Position 2 = 7
Branch analysis from position: 23
Branch analysis from position: 7
filename:       /in/OM8HP
function name:  (null)
number of ops:  31
compiled vars:  !0 = $array, !1 = $result, !2 = $count, !3 = $current, !4 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    5     1        ASSIGN                                                   !1, <array>
    6     2        ASSIGN                                                   !2, 0
    7     3        FETCH_DIM_R                                      ~8      !0, 0
          4        ASSIGN                                                   !3, ~8
    8     5        ASSIGN                                                   !4, 0
          6      > JMP                                                      ->20
    9     7    >   FETCH_DIM_R                                      ~11     !0, !4
          8        IS_EQUAL                                                 !3, ~11
          9      > JMPZ                                                     ~12, ->12
   10    10    >   PRE_INC                                                  !2
         11      > JMP                                                      ->17
   13    12    >   INIT_ARRAY                                       ~15     !3
         13        ADD_ARRAY_ELEMENT                                ~15     !2
         14        ASSIGN_DIM                                               !1
         15        OP_DATA                                                  ~15
   14    16        ASSIGN                                                   !2, 1
   16    17    >   FETCH_DIM_R                                      ~17     !0, !4
         18        ASSIGN                                                   !3, ~17
    8    19        PRE_INC                                                  !4
         20    >   COUNT                                            ~20     !0
         21        IS_SMALLER                                               !4, ~20
         22      > JMPNZ                                                    ~21, ->7
   18    23    >   INIT_ARRAY                                       ~23     !3
         24        ADD_ARRAY_ELEMENT                                ~23     !2
         25        ASSIGN_DIM                                               !1
         26        OP_DATA                                                  ~23
   19    27        INIT_FCALL                                               'print_r'
         28        SEND_VAR                                                 !1
         29        DO_ICALL                                                 
         30      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
170.16 ms | 1396 KiB | 15 Q