Banner

Sponsor

Login


Welcome Back!
Guest
Guest

Register

Lost your password?

97 users online



strip domain from email addy and write to a text file

strip domain from email addy and write to a text file

Currently viewing this thread: 1 (0 members and 1 guests)


nertman

nertman

lurker
Status: Offline!

strip domain from email addy and write to a text file

i'm looking to strip the domain off an email address like this

open emaillist.txt
eplode @ for each email address
write $doman to newlist.txt (and echo each)

PHP:

<?php
$Lines 
file("emails.txt");
foreach(
$Lines as $Key => $Val
{
   
$Data[$Key] = explode("@"$Val);
}
for(
$K 0$K sizeof($Lines); $K++) 

   echo 
'.'$Data[$K][1]'.';
}
?>


problem is i'm not to great and doing arrays+loops i know how to open a file and write to a file and basic's on loops/arrays.

//edit
just needed to modify this line:
echo '.'$Data[$K][1]'.';

to make it work properly :] didn't bother with having it to write to another file

Last edited by nertman, December 29th, 2006 07:20 AM (Edited 1 times)

howdy

howdy

Neverside Newbie
Status: Offline!

The spoono tutorial (I believe is where you got your code from), is using multiple data on each line of the text file. In your case you don't need that. Unless I am missing something?

I believe the code below will work for you.

PHP:

<?php
$Lines 
file("emails.txt");
$file fopen("newlist.txt""w");
for(
$K 0$K sizeof($Lines); $K++) 
{
   
$pos strrpos($Lines[$K], "@");
   
$str substr($pos+1);
   echo 
$str;
   
fwrite($file$str);

}
fclose($file);
?>

___________________

Haudenschilt.com

Last edited by howdy, December 29th, 2006 04:29 PM (Edited 1 times)

Quick Jump:

Main Navigation


Site & Graphic Design by Aeon Tan
Developed by Jeremie Pelletier & Scott Roach


NeverAPI generated this page in 0.0074 seconds.