im not a fruit, just pressed for time...
Moderator: General Moderators
im not a fruit, just pressed for time...
And frankly you guys rule...
second problem; that i have been unsuccessful at...
have a huge text file that has 20000 lines in it in the format of
useremail, password, name
user1, password, name &stuff
jim@walrii.com, password, name..
user4, password, name...
Is there a way to go thru it line by line and grab anything that looks like an email address and output it to a file in mail-able format... ie jim@ie.com;walrus@npole.net;etc@etc.etc ...
I'll love you for life
second problem; that i have been unsuccessful at...
have a huge text file that has 20000 lines in it in the format of
useremail, password, name
user1, password, name &stuff
jim@walrii.com, password, name..
user4, password, name...
Is there a way to go thru it line by line and grab anything that looks like an email address and output it to a file in mail-able format... ie jim@ie.com;walrus@npole.net;etc@etc.etc ...
I'll love you for life
okay.. almost there.. i think
Having a tough time pushing this one...
this looks right to me...
but im getting the error
Warning: Unknown modifier '+' in /usr/local/apache/htdocs/www/test/index.php on line 11
Array
Thanks guys I appreciate the help
this looks right to me...
but im getting the error
Warning: Unknown modifier '+' in /usr/local/apache/htdocs/www/test/index.php on line 11
Array
Code: Select all
<?
$filename = "/usr/local/apache/htdocs/www/test/westol.txt";
$myfile = fopen($filename,"r+") or die("fopen failed");
$contents = fread($myfile, filesize($filename));
$pattern = ".+@.+..";
$pattern1 = "(їa-zA-z0-9]+ї.+-]?)+@(їa-zA-z0-9+-]+.)+(їa-zA-Z]{2,3})";
preg_match_all($pattern1, $contents, $emails);
echo "$emails";
fclose($myfile);
?>Code: Select all
- sam
- Forum Contributor
- Posts: 217
- Joined: Thu Apr 18, 2002 11:11 pm
- Location: Northern California
- Contact:
First this is a very bad idea:
If you file is 20,000 lines long this will tare your webserver a new one. Use the folowing funtions:
This will greatly reduce the memory usage and is far less cpu intensive.
btw here is the php man for fscanf
http://www.php.net/manual/en/function.fscanf.php
Cheers Sam
Code: Select all
$contents = fread($myfile, filesize($filename));Code: Select all
while ($userinfo = fscanf ($fp, "%s,%s,%s
")){
//... do some stuff with your data
}btw here is the php man for fscanf
http://www.php.net/manual/en/function.fscanf.php
Cheers Sam
- sam
- Forum Contributor
- Posts: 217
- Joined: Thu Apr 18, 2002 11:11 pm
- Location: Northern California
- Contact:
hehe thanks
You could do something like this:
I must go now, time to reinstall IE6.
Cheers Moe
You could do something like this:
Code: Select all
$fp = fopen("your_file","r");
$i=0;
while ($userinfo = fscanf ($fp, "%s,%s,%s
")){
// The array $userinfo now contains one row from your text file
// (pending that there are no formating error in it)
if(ereg("ї:alnum:]*@ї:alnum:]*ї.]їa-zA-Z0-9.]{2,6}",$userinfoї0])){
$emailї$i++] = $userinfoї0];
}
}
You now have an array $email that contains all the email address that are syntheticly valid.Cheers Moe
hmm
i tried that, i got no errors, but no results either...
the page was entirely blank... (even the source)
I even made sure i put a samrules@hisplace.com
to check it
i tried that, i got no errors, but no results either...
the page was entirely blank... (even the source)
Code: Select all
<?
$filename = "/usr/local/apache/htdocs/www/test/westol.txt";
$fp = fopen($filename,"r");
$i=0;
while ($userinfo = fscanf ($fp, "%s,%s,%s
")){
// The array $userinfo now contains one row from your text file
// (pending that there are no formating error in it)
if(ereg("ї:alnum:]*@ї:alnum:]*ї.]їa-zA-Z0-9.]{2,6}",$userinfoї0])){
$emailї$i++] = $userinfoї0];
echo $emailї$i];
}
}
?>to check it
- sam
- Forum Contributor
- Posts: 217
- Joined: Thu Apr 18, 2002 11:11 pm
- Location: Northern California
- Contact:
try both:
and adding a different expression, that one has never been tested I might have put an error in it.
Code: Select all
$userinfo = fscanf ($fp, "%s
")){same thing.. completely blank...
I'll read some more...
if you wanna see it http://www.jeepsunpaved.com/text/index.php
I'll read some more...
if you wanna see it http://www.jeepsunpaved.com/text/index.php