PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
shaqa
Forum Commoner
Posts: 62 Joined: Mon Aug 13, 2007 9:11 am
Post
by shaqa » Sun Mar 29, 2009 6:19 pm
i have a text file with text on it and emails, how can i gather only emails from a text file and echo those.
email is in this mode:
email.com can be: hotmail,yahoo,msn etc..
i was using but it doesnt work:
Code: Select all
$file = 'datafile.txt';
$lines = file($file);
foreach ($lines as $line)
{
$split = explode(' - ', $line);
$name = $split[0];
$id = $split[1]
if($split[0] == $name_I_am_searching_for)
{
//stop searching and show the result
}
}
requinix
Spammer :|
Posts: 6617 Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA
Post
by requinix » Sun Mar 29, 2009 7:37 pm
Post an example of the text file, it'll help us.
shaqa
Forum Commoner
Posts: 62 Joined: Mon Aug 13, 2007 9:11 am
Post
by shaqa » Mon Mar 30, 2009 5:32 pm
Search For: Sample, Sample, Sample
Sample: Sample
----------------------------------------------------------------------------------------------------
Start Search Number 1...
1 Sample Sample Sample Sample Sample Sample email:
sSample09@gmail.com
requinix
Spammer :|
Posts: 6617 Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA
Post
by requinix » Mon Mar 30, 2009 9:08 pm
So basically, whatever comes after an "email: "?
Code: Select all
$file = file_get_contents("datafile.txt");
preg_match_all('/(?<=email: )\S+/', $file, $matches);
print_r($matches[0]);
shaqa
Forum Commoner
Posts: 62 Joined: Mon Aug 13, 2007 9:11 am
Post
by shaqa » Thu Apr 02, 2009 6:38 pm
im receiving lik :
Array ( [0] => Array ( [0] =>
samplemail9@gmail.com [1] => and so and so.
i want to show one email per line like:
sample@samp.com
sampel2.@gmpa.com etc,,
thank you