Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8346315
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T06:58:22+00:00 2026-06-09T06:58:22+00:00

I have an array of values, all strings. There are also 2 marker entries

  • 0

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:

$array['1','2','3','A','5','6','7','B','8','9']

I need to retrieve the array indices after A, but before B. So, in this example, the indices of 5, 6, and 7.

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 🙂

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).

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.

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);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T06:58:24+00:00Added an answer on June 9, 2026 at 6:58 am

    I think this should work:

    $result = array();
    $start = "A";
    $stop = "B";
    $push = false;
    foreach($array as $value) {
        if ($value == $start) {
             $push = true;
        } else if ($value == $stop) {
            break;
        }
        if ($push) {
            $result[] = $value;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just have the array of 15 values that all need to be inserted
I have an array of array like below with all numeric values. I want
I have an array of values all well within the range 0 - 63,
I have classname stored in variable $classname; also I have an array of values
So I have an array. The array has string values inside that can change
I have an array of values, I was wondering how I can parse certain
I have an array of values which is almost, but not quite sorted, with
Suppose I have an array of values [a,b,c,d,...] and a function f(x,...) which returns
Let's say I have an array var test = new Array() the values in
I have an array with allowed values and an array with given values. Howto

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.