How do i use this str_replace with this

bla@bla.com
blac@bla.com
namit@namit.com
and so on

so i have setup

$email = str_replace(" ", ", ", $mail_list);

but it will only talk details if i do this

blac@bla.com bla@bla.com

It does not seam to find and replace return

Recommended Answers

All 2 Replies

How do i use this str_replace with this

bla@bla.com
blac@bla.com
namit@namit.com
and so on

so i have setup

$email = str_replace(" ", ", ", $mail_list);

but it will only talk details if i do this

blac@bla.com bla@bla.com

It does not seam to find and replace return

The 'return' character is not a space, it is '\n'.

-Fredric

Not sure how the email list are stored... If they are stored in txt file, then you can use fread to read each line of email address into a string:

$mail_list = '';
$handle = @fopen("/tmp/inputfile.txt", "r");
if ($handle) {
   while (!feof($handle)) {
       $buffer = fgets($handle, 1024);
       $mail_list .= $buffer.',';  // email addresses
   }
   fclose($handle);
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.