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

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

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

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