How to Extract All Email Addresses from String in PHP?

Oct 21, 2021 . Admin

Hi Guys,

Today, In this example, I would like to share with you how to find all email addresses in string PHP.

So, mainly PHP find the email in the string, PHP finds all email addresses in the string, PHP check email string, how to extract email address from text string PHP, PHP extract emails from the string.

Here, I will give you a full example of PHP extracting emails from the string so follow mine below steps.

    $string = 'This email is and company email is';
    $pattern = '/[a-z0-9_\-\+\.]+@[a-z0-9\-]+\.([a-z]{2,4})(?:\.[a-z]{2})?/i';
    preg_match_all($pattern, $string, $matches);

    [0] =>
    [1] =>

It will help you...