FREE PHP Scripts and Snippets

Ready to use Free PHP scripts and snippets to use in your projects.
All Free Scripts & Snippets Complete PHP Scripts

PHP extract multiple emails from text

>> Share on Facebook & Impress your friends <<

PHP Script to scan a text and extract all email ids contained in the text. It outputs email addresses as comma separated list.


Name : PHP extract multiple emails from text

Function expects one parameter which is the text from which email addresses are to be extracted.

It outputs email ids as comma separated list.


function extractMultipleEmailsFromText($text){
    // Define the regular expression from extracting email addresses
    $regexp = '/([a-z0-9_\.\-])+\@(([a-z0-9\-])+\.)+([a-z0-9]{2,4})+/i';
	// Now use it to actually extract email addresses to array
    preg_match_all($regexp, $text, $m);
	// Now convert it into comma separated list of email addresses
	$email_addresses=implode( ", ",$m[0]);
	// Now return the list of extracted email addresses
	return $email_addresses;
} // End of Exctract Multiple Emails From Text function

// Let us write some dummy text to test  it
$test_string = 'Let us put some text here

and some other text

and then 

//Lets have fun and echo the result to see if it works!
echo extractMultipleEmailsFromText($test_string);


Request Custom Snippet

Just $5 Onwards


Previously Ordered Snippets

Extract all email addresses from all .txt files in a folder.
Price $10 Order Now

PHP script to extract email addresses from a web page by providing its URL.
Price $5 Order Now

PHP script to extract multiple URLs from a text.
Price $5 Order Now

I want a PHP snippet to extract all Values from a select list along with their texts and return it as an array.
Price $5 Order Now

I want PHP snippet to extract Texts in all anchor tags on a web page. Basically whole linked text.
Price $5 Order Now

Random PHP Scripts and Snippets

Extracting all numbers from a String [PHP]

This PHP function extracts all numbers from a String and prints them as a comma separated list of numbers. Ready...

PHP Code to list all files in a folder

This PHP Code snippet lists all files in a folder and hyperlinks them accordingly. Very clean, easy to use function....

Create URL Slug from text string [PHP]

PHP Script to create URL from string. It retails only URL Safe characters in the strings. So, now easily create...

Free PHP folder to gallery script

100% Free PHP folder to gallery script. Just give the name of folder and it will generate gallery of all...

[PHP] Time ago calculation function

It is a very nice PHP time ago function. You gave pass any date to it and it will tell...

Generate Random Password in PHP

PHP Script to Generate Random Password. You can set the list of characters that you want to be used in...

PHP Create thumbnail of an image

PHP Script to create thumbnail of any image (.jpg, .png and .gif). This create thumbnail function is ready to use....

Detect Valid Email address with PHP

A very simple php snippet to check if an email id is valid or not. If the email address is...