title: how can I retrieve the values of an array between 2 markers in PHP?
body: <p>I have an array of values, all strings. There are also 2 "marker" entries in the array, that signify what the values that follow are. Basically it's set up like so:</p>
  
  <p><code>$array['1','2','3','A','5','6','7','B','8','9']</code></p>
  
  <p>I need to retrieve the array indices <em>after</em> <strong>A</strong>, but <em>before</em> <strong>B</strong>. So, in this example, the indices of 5, 6, and 7.</p>
  
  <p>I was thinking about doing this with a forloop and some iterative if statements.. But I can't seem to figure it out. Any help is much appreciated :)</p>
  
  <p>EDIT: also worth noting that A and B are not always at the same position in the array; some users will have more data between A and B than others, some won't have A and B at all. But if A is present, I need to get the values following it. If A and B are present they will also always have the same value (A and B).</p>
  
  <p>EDIT2: This is what I'm currently trying as per PeeHaa's suggestions. A is "registered:current" and B is "registered:next". In his testing he is getting the value that comes after A but before B, however in my tests I am only getting the value of A ("registered:current"). It just outputs "registered:current" instead of the value that exists between the 2 markers.</p>
  
  <pre><code>function getValuesBetweenMarkers($theArray, $startMarker = 'registered:current', $endMarker = 'registered:next')
  {
      $offset = array_search($startMarker, $theArray) + 1;
      $length = array_search($endMarker, $theArray) - $offset;
  
      return array_slice($theArray, $offset, $length, true);
  }
  </code></pre>