I'm still learning a lot about PHP and string alteration is something that is of interest to me. I've used preg\_match before for things like validating an email address or just searching for inquiries.

I just came from this post [What's wrong in my regular expression?](https://stackoverflow.com/questions/7827846/whats-wrong-in-my-regular-expression) and was curious as to why the preg\_match\_all function produces 2 strings, 1 w/ some of the characters stripped and then the other w/ the desired output.

From what I understand about the function is that it goes over the string character by character using the RegEx to evaluate what to do with it. Could this RegEx have been structured in such a way as to bypass the first array entry and just produce the desired result?

and so you don't have to go to the other thread

```
$str = 'text^name1^Jony~text^secondname1^Smith~text^email1^example-
        free@wpdevelop.com~';

preg_match_all('/\^([^^]*?)\~/', $str, $newStr);

for($i=0;$i<count($newStr[0]);$i++)
{
    echo $newStr[0][$i].'<br>';
}

echo '<br><br><br>';

for($i=0;$i<count($newStr[1]);$i++)
{
    echo $newStr[1][$i].'<br>';
} 

```

This will output

> 
> ^Jony~  
> ^Smith~  
> ^example-free@wpdevelop.com~  
>   
>   
> Jony  
> Smith  
> example-free@wpdevelop.com
> 
> 
> 

I'm curious if the reason for 2 array entries was due to the original sytax of the string or if it is the normal processing response of the function. Sorry if this shouldn't be here, but I'm really curious as to how this works.

thanks,
Brodie