Search code examples
phpemail-address

Remove phrases from string


I have a string like this:

..., "test1@test1.com" <test1@test1.com>, "test2@test2.com" <test2@test2.com>, "test3@test3.com", "test4@test4.com" <test4@test4.com>, ....

I am exploding everything by , , but problem is that i dont want to have value laike this [0] => "test1@test1.com" <test1@test1.com> i need to remove the emails which are in those <..> brackets.

So the result should be like this [0] => test1@test1.com. Any offers how to drop the second phrase?


Solution

  • <?php
    $str = '"test1@test1.com" <test1@test1.com>';
    $str= preg_replace("(<.*>+)", "", $str);
    print $str;
    ?>