Search code examples
phpemail-address

Remove phrases from string


I have a string like this:

..., "[email protected]" <[email protected]>, "[email protected]" <[email protected]>, "[email protected]", "[email protected]" <[email protected]>, ....

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

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


Solution

  • <?php
    $str = '"[email protected]" <[email protected]>';
    $str= preg_replace("(<.*>+)", "", $str);
    print $str;
    ?>