I have a string

```
$string= '<Label>1</Label><Value>1</Value><Label>2</Label><Value>2</Value><Label>3</Label><Value>3</Value><Label>4</Label><Value>4</Value><Label>5</Label><Value>5</Value>';

```

I need to separate the Label and Value tag values into two separate arrays. I tried to use the following function

```
function getTextBetweenTags($string, $tagname) 
{
    $pattern = "/<$tagname>(.*)<\/$tagname>/";
    preg_match($pattern, $string, $matches, PREG_OFFSET_CAPTURE);
    return $matches;
}

```

I created another function to make it two separate arrays

```
function formatChoices($choices)
{
    $return['label'] = $this->getTextBetweenTags($choices, "Label");
    $return['value'] = $this->getTextBetweenTags($choices, "Value");

    return $return;
}

```

But it returns the following

```
Array([label] => Array(
        [0] => 1</Label><Value>1</Value><Label>2</Label><Value>2</Value><Label>3</Label><Value>3</Value><Label>4</Label><Value>4</Value><Label>5
        [1] => 7
    )

[value] => Array
    (
        [0] => 1</Value><Label>2</Label><Value>2</Value><Label>3</Label><Value>3</Value><Label>4</Label><Value>4</Value><Label>5</Label><Value>5
        [1] => 23))

```

Please help. Thanks