Split a string, remember the positions of splitting
<p>Assume I have the following string:</p>

<pre><code>I have | been very busy lately and need to go | to bed early
</code></pre>

<p>By splitting on "|", you get:</p>

<pre><code>$arr = array(
  [0] =&gt; I have
  [1] =&gt; been very busy lately and need to go
  [2] =&gt; to bed early
)
</code></pre>

<p>The first split is after 2 words, and the second split 8 words after that. The positions after how many words to split will be stored: array(2, 8, 3). Then, the string is imploded to be passed on to a custom string tagger:</p>

<pre><code>tag_string('I have been very busy lately and need to go to bed early');
</code></pre>

<p>I don't know what the output of tag_string will be exactly, except that the total words will remain the same. Examples of output would be:</p>

<pre><code>I have-nn been-vb very-vb busy lately and-rr need to-r go to bed early-p
I-ee have been-vb very busy-df lately-nn and need-f to go to bed-uu early-yy
</code></pre>

<p>This will lengthen the string by an unknown number of characters. I have no control over tag_string. What I know is (1) the number of words will be the same as before and (2) the array was split after 2, and thereafter after 8 words, respectively. I now need a solution explode the tagged string into the same array as before:</p>

<pre><code>$string = "I have-nn been-vb very-vb busy lately and-rr need to-r go to bed early-p"
function split_string_again() {
  // split after 2nd, and thereafter after 8th word
}
</code></pre>

<p>With output:</p>

<pre><code>$arr = array(
  [0] =&gt; I have-nn
  [1] =&gt; been-vb very-vb busy lately and-rr need to-r go
  [2] =&gt; to bed early-p
)
</code></pre>

<p>So to be clear (I wasn't before): I cannot split by remembering the strpos, because strpos before and after the string went through the tagger, aren't the same. I need to count the number of words. I hope I have made myself more clear :)</p>
