• Welcome to AcornDomains.co.uk, a friendly community for UK domain investors, developers and anyone interested in domain names.

    Whether you're looking to buy or sell domains, learn more about the UK domain market, get feedback on your names, or simply chat with other domainers, you're in the right place. AcornDomains has been bringing together people from across the UK domain industry for many years, from complete beginners to experienced investors.

    Have a look around, join the discussions and, if you haven't already, create a free account and introduce yourself.

Script to extract emails

Status
Not open for further replies.

AdminAdmin is verified member.

Administrator
Acorn Staff
Acorn Moderator
Developer
Server Admin
Nominet Registrar
Joined
Jun 14, 2004
Posts
11,191
Reaction score
1,059
This is a simple PHP SCRIPT which allows the user to extract emails ids from any form of text.This proves really useful when we have a bundle of email ids in a raw format and just want to get into into a database in an orderly fashion.

<?php

//Function to extract the email IDS

function extract_emails($text_content){

//Matching the content of the content file against the email id format

preg_match_all(“/[\._a-zA-Z0-9-]+@[\._a-zA-Z0-9-]+/i”, $text_content, $match_email);

return $ match_email [0];

}

//Getting the content of the test file

$text = file_get_contents(“content.txt”);”;

//Calling the function to extract the email ids

$emails = extract_emails($text);

//Displaying the email ids in individuals lines

print(implode(“\n”, $emails));

?>
 
Status
Not open for further replies.
Top Bottom