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.

<?php
/*

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

test1@mysite.com

and some other text 

what1@where.com


and then test8@nothing.org 
';

//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

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...

PHP - Extract all links from a web page

PHP Script to extract all links from a web page. This PHP Snippet reads the contents of a web page...

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] generate keywords from text function

This is a simple function written in PHP to generate keywords from any text. Just pass any free text to...

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 extract multiple emails from text

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

[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...