Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > Linux Forums > Programming/Scripts

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 31st January 2008, 11:36
edge edge is offline
Moderator
 
Join Date: Dec 2005
Location: The Netherlands
Posts: 2,036
Thanks: 268
Thanked 153 Times in 133 Posts
Default filter email addresses (in PHP)

I have a list here with some email addresses that need to be "cleaned"
The list is in a text file, and looks like this
* the list does have more email addresses, and this is only an example.

Now I need some PHP code to ONLY show all the email addresses from domain1.com (and if needed only from domain2.com or domain3.com ect...)

Someone here who can show me how this is done? (I guess it needs to make use of a wild card for the pre @ part)

Thank you
__________________
Never execute code written on a Friday or a Monday.
Reply With Quote
Sponsored Links
  #2  
Old 1st February 2008, 09:21
topdog topdog is offline
Senior Member
 
Join Date: Jan 2008
Location: South Africa
Posts: 1,352
Thanks: 0
Thanked 153 Times in 150 Posts
Default

Code:
<?php
# andrew@topdog.za.net
#
$file = "path_to_file";
$domain = "domain1.com";

if(file_exists($file)){
        $x = fopen($file,"r");
        if($x){
                while(!feof($x)){
                        $b = fgets($x, 4096);
                        if (eregi($domain, $b))
                                print "$b\n";

                }
                fclose($x);
        }
}else{
        print "File $file does not exist";
}
?>
__________________
----
http://www.topdog.za.net - Got Linux problems ? - I can help.
http://www.baruwa.org - Try it.
Reply With Quote
The Following User Says Thank You to topdog For This Useful Post:
edge (1st February 2008)
  #3  
Old 1st February 2008, 09:35
edge edge is offline
Moderator
 
Join Date: Dec 2005
Location: The Netherlands
Posts: 2,036
Thanks: 268
Thanked 153 Times in 133 Posts
 
Default

Thank you Andrew!

I'll be testing your code later today.
__________________
Never execute code written on a Friday or a Monday.
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Freebsd 6.1 support misterm Installation/Configuration 10 9th April 2009 09:29
php eating cpu shajazzi Server Operation 15 15th August 2007 01:19
Apache2 Freezes celtic Server Operation 31 28th May 2007 17:18
Transferring Hard Drive to new System latcarf Installation/Configuration 26 20th February 2007 18:51
ubuntu ispconfig joomla .htaccess steve1084 General 8 6th January 2007 15:55


All times are GMT +2. The time now is 13:02.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.