3v4l.org

run code in 300+ PHP versions simultaneously
<?php function SplitIntoGroups($array) { $toReturnArray = array(); $currentNumber = $array[0]; $currentCount = 1; for($i=1; $i <= count($array); $i++) { if($array[$i] == $currentNumber) { $currentCount++; } else { $toReturnArray[] = array($currentNumber, $currentCount); $currentNumber = $array[$i]; $currentCount = 1; } } return $toReturnArray; } $answer = SplitIntoGroups(array(1,1,1,2,2,3,3,1,1,2,2,3)); for($i=0; $i<count($answer); $i++) { echo '[' . $answer[$i][0] . '] = ' . $answer[$i][1] . '<br />'; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
2 jumps found. (Code = 44) Position 1 = 19, Position 2 = 6
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
2 jumps found. (Code = 44) Position 1 = 19, Position 2 = 6
Branch analysis from position: 19
Branch analysis from position: 6
filename:       /in/NjqGF
function name:  (null)
number of ops:  20
compiled vars:  !0 = $answer, !1 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   INIT_FCALL                                               'splitintogroups'
          1        SEND_VAL                                                 <array>
          2        DO_FCALL                                      0  $2      
          3        ASSIGN                                                   !0, $2
   25     4        ASSIGN                                                   !1, 0
          5      > JMP                                                      ->16
   27     6    >   FETCH_DIM_R                                      ~5      !0, !1
          7        FETCH_DIM_R                                      ~6      ~5, 0
          8        CONCAT                                           ~7      '%5B', ~6
          9        CONCAT                                           ~8      ~7, '%5D+%3D+'
         10        FETCH_DIM_R                                      ~9      !0, !1
         11        FETCH_DIM_R                                      ~10     ~9, 1
         12        CONCAT                                           ~11     ~8, ~10
         13        CONCAT                                           ~12     ~11, '%3Cbr+%2F%3E'
         14        ECHO                                                     ~12
   25    15        PRE_INC                                                  !1
         16    >   COUNT                                            ~14     !0
         17        IS_SMALLER                                               !1, ~14
         18      > JMPNZ                                                    ~15, ->6
   28    19    > > RETURN                                                   1

Function splitintogroups:
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 = 19
Branch analysis from position: 19
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/NjqGF
function name:  SplitIntoGroups
number of ops:  25
compiled vars:  !0 = $array, !1 = $toReturnArray, !2 = $currentNumber, !3 = $currentCount, !4 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    4     1        ASSIGN                                                   !1, <array>
    5     2        FETCH_DIM_R                                      ~6      !0, 0
          3        ASSIGN                                                   !2, ~6
    6     4        ASSIGN                                                   !3, 1
    7     5        ASSIGN                                                   !4, 1
          6      > JMP                                                      ->20
    9     7    >   FETCH_DIM_R                                      ~10     !0, !4
          8        IS_EQUAL                                                 !2, ~10
          9      > JMPZ                                                     ~11, ->12
   11    10    >   PRE_INC                                                  !3
         11      > JMP                                                      ->19
   15    12    >   INIT_ARRAY                                       ~14     !2
         13        ADD_ARRAY_ELEMENT                                ~14     !3
         14        ASSIGN_DIM                                               !1
         15        OP_DATA                                                  ~14
   16    16        FETCH_DIM_R                                      ~15     !0, !4
         17        ASSIGN                                                   !2, ~15
   17    18        ASSIGN                                                   !3, 1
    7    19    >   PRE_INC                                                  !4
         20    >   COUNT                                            ~19     !0
         21        IS_SMALLER_OR_EQUAL                                      !4, ~19
         22      > JMPNZ                                                    ~20, ->7
   21    23    > > RETURN                                                   !1
   22    24*     > RETURN                                                   null

End of function splitintogroups

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.56 ms | 1403 KiB | 14 Q