title: How to count the consecutive duplicate values in an array?
body: <p>I have an array like this:</p>
  
  <pre><code>$arr = array(1, 1, 1, 2, 2, 3, 3, 1, 1, 2, 2, 3);
  </code></pre>
  
  <p>I found the function <code>array_count_values()</code>, but it will group all of the same values and count the occurrences without respecting breaks in the consecutive sequences.</p>
  
  <pre><code>$result[1] = 5
  $result[2] = 4
  $result[3] = 3
  </code></pre>
  
  <p>How can I group each set of consecutive values and count the length of each sequence?  Notice there are two sets of sequences for the numbers <code>1</code>, <code>2</code>, and <code>3</code>.</p>
  
  <p>The data that I expect to generate needs to resemble this:</p>
  
  <pre><code>[1] = 3;
  [2] = 2;
  [3] = 2;
  [1] = 2;
  [2] = 2;
  [3] = 1;
  </code></pre>