Question: I have a string that contains some values I need to extract. Each of these values is surrounded by a common character. 

What is the most efficient way to extract all of these values into an array?

For example, given the following string:

```
stackoverflowis%value1%butyouarevery%value2%

```

I would like to get an array containing `value1` and `value2`

Answer: 
Use `explode` and take the odd-indexed values from the resulting array. You indicated you wanted the most efficient method, and this will be faster than a regex solution.

```
$str = 'stackoverflowis%value1%butyouarevery%value2%';
$arr = explode('%', $str);

$ct = count($arr);

for ($i = 1; $i < $ct; $i += 2) {
    echo $arr[$i] . '<br />';
}

```
```
preg_match_all('/%([^%]+)%/', $s, $match);
var_dump($match[1]);

```