3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = array(1,1,1,2,2,3,3,1,1,2,2,3); $result = array(); $prev_value = array('value' => null, 'amount' => null); foreach ($arr as $val) { if ($prev_value['value'] != $val) { unset($prev_value); $prev_value = array('value' => $val, 'amount' => 0); $result[] =& $prev_value; } $prev_value['amount']++; } echo ($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 17
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 17
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 14
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 14
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
filename:       /in/Nu9um
function name:  (null)
number of ops:  20
compiled vars:  !0 = $arr, !1 = $result, !2 = $prev_value, !3 = $val
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    4     1        ASSIGN                                                   !1, <array>
    5     2        ASSIGN                                                   !2, <array>
    7     3      > FE_RESET_R                                       $7      !0, ->17
          4    > > FE_FETCH_R                                               $7, !3, ->17
    8     5    >   FETCH_DIM_R                                      ~8      !2, 'value'
          6        IS_NOT_EQUAL                                             !3, ~8
          7      > JMPZ                                                     ~9, ->14
    9     8    >   UNSET_CV                                                 !2
   10     9        INIT_ARRAY                                       ~10     !3, 'value'
         10        ADD_ARRAY_ELEMENT                                ~10     0, 'amount'
         11        ASSIGN                                                   !2, ~10
   11    12        FETCH_DIM_W                                      $12     !1
         13        ASSIGN_REF                                               $12, !2
   14    14    >   FETCH_DIM_RW                                     $14     !2, 'amount'
         15        PRE_INC                                                  $14
    7    16      > JMP                                                      ->4
         17    >   FE_FREE                                                  $7
   17    18        ECHO                                                     !1
         19      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.65 ms | 1394 KiB | 13 Q